Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3632590
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:32:39+00:00 2026-05-19T00:32:39+00:00

I have a site that is using custom fields, and I want to either

  • 0

I have a site that is using custom fields, and I want to either show the content for the field if the field is being used, and if the field is not being used per a Post then of course don’t show the contents of the fields.

Seems my code below is not correct, as it is showing the content in the else block when the Post is not using any of the custom fields.

Any help would be greatly appreciated!

Here is the Post in question:
http://beta.ohsinsider.com/insider-top-stories/workers%E2%80%99-compensation-may-not-shield-you-from-lawsuits-by-injured-workers

Here is the Post Edit showing that the field I am calling in my code are not being used (http://screencast.com/t/aBjt1drIw).

I have confirmed that when I do input the value for the custom field is it being outputted in the Post.

Here is the code I am using:

<?php
    $pdfurl = get_post_meta($post->ID, 'pdf', true);
    $wordurl = get_post_meta($post->ID, 'word', true);
    if( !empty($pdf) || !empty($word) ){
    ?>
    <?php /* show nothing then */ } else { ?>
    <div id="post_downloads_box">
        <h3 class="single_related_footer">Dfownload Now</h3>
        <div id="post_downloads_box_left">
            <a target="_blank" href="<?php echo get_post_meta($post->ID, 'pdf', true); ?>"><img src="<?php bloginfo('template_url'); ?>/images/post_pdf_icon.jpg" /></a>
        </div>
        <div id="post_downloads_box_right">
            <a target="_blank" href="<?php echo get_post_meta($post->ID, 'word', true); ?>"><img src="<?php bloginfo('template_url'); ?>/images/post_word_icon.jpg" /></a>
        </div>
    </div>
    <?php } ?>  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T00:32:39+00:00Added an answer on May 19, 2026 at 12:32 am

    Seems this is better:

    <?php $values = get_post_custom_values("pdf"); if (isset($values[0])) {?>
        <div id="post_downloads_box">
            <h3 class="single_related_footer">Dfownload Now</h3>
            <div id="post_downloads_box_left">
                <a target="_blank" href="<?php echo get_post_meta($post->ID, 'pdf', true); ?>"><img src="<?php bloginfo('template_url'); ?>/images/post_pdf_icon.jpg" /></a>
            </div>
            <div id="post_downloads_box_right">
                <a target="_blank" href="<?php echo get_post_meta($post->ID, 'word', true); ?>"><img src="<?php bloginfo('template_url'); ?>/images/post_word_icon.jpg" /></a>
            </div>
        </div>
        <?php } else {} ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site that is using x509 client certificates (2 way SSL) to
I have a site that I am currently working on in ASP.NET 2.0 using
I have a simple Tray icon program that opens a site using System.Diagnostics.Process.Start(URL) And
I have one site that is displaying html content that needs to be displayed
I have a page layout for my MOSS '07 site that I want put
I have two roles being used on my site currently, author & admin. Authors
I have an ASP.NET MVC 3 site using a custom route for specifying the
I have a site that requires Windows Authentication the application obtains the credential from
I have a site that usually has news items at the top of the
I have a site that I've developed that makes decent use of Javascript, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.