flint_and_tinder
Member
Posted 6 months ago #
Hi all,
I'm trying to display the contents of a custom field with auto p tags if the content field has been added. So far I have this but it doesn't work, can anyone help with what I'm doing wrong please?
<?php if ( get_post_meta($post->ID, 'credits', true) ) : ?>
<aside class="credits">
<?php echo apply_filters('the_content', $credits); ?>
</aside>
<?php endif; ?>
Try it with this [untested]:
<?php
$credits = get_post_meta($post->ID, 'credits', true);
if ($credits != '' ) : ?>
<aside class="credits">
<?php echo apply_filters('the_content', $credits); ?>
</aside>
<?php endif; ?>
flint_and_tinder
Member
Posted 6 months ago #
Ignore the above, I got myself in a pickle. The code below works ok.
<?php if( $credits = get_post_meta($post->ID, 'credits', true) ): ?>
<aside class="credits">
<?php echo apply_filters('the_content', $credits); ?>
</aside>
<?php endif; ?>
flint_and_tinder
Member
Posted 6 months ago #
Thanks Keesiemeijer, it seems your code works as well.