Custom Fields doesn't show up (results.php)

Forums › Forums › General › Custom Fields doesn't show up (results.php)

Viewing 3 posts – 1 through 3 (of 3 total)
  • Anonymous
    #213031

    Hello

    I’ve been trying to style my template (results.php). It works almost perfectly, but then I’ll do this code:

    Skrevet af <?php echo get_post_meta($post->ID, 'bfo', true); ?><br>
              Sprog: <?php echo get_post_meta($post->ID, 'bogens_sprog', true); ?><br>
              Udgivet i <?php echo get_post_meta($post->ID, 'udgivelsesar', true); ?><br>
    		  <?php the_tags( 'Subject(r): ', ', ', '<br />' ); ?>
              <?php if(function_exists('the_ratings')) { the_ratings(); } ?>

    bfo, bogens_sprog and udgivelsesar are custom fields, that are showing other places (including the filter options), but on the archive page it’s just empty text. Why don’t the text show up?

    Anonymous
    #213032

    Found the solution myself!

    <?php echo get_field('bfo'); ?>

    did the trick

    Trevor
    #213056

    Great to see this, but it would be better to test if the field has a value before echoing it, maybe like this:

    <?php if( get_field('bfo') ):?>
    <p>BFO: <?php the_field('bfo'); ?></p>
    <?php endif; ?>

    I will close this thread for now.

Viewing 3 posts – 1 through 3 (of 3 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.