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)