I want to add text “Genre:” to the beginning of this custom field
JavaScript
x
<?php the_field('im_genre'); ?>
the reason that i dont simply add something like this
JavaScript
<li>Genre:<?php the_field('im_genre'); ?> </li>
is that i dont want to this text be shown when there isnt this field for a post
Advertisement
Answer
You can check if the field exists and then display your HTML element.
JavaScript
<?php if( get_field('im_genre') ): ?>
<li>Genre:<?php the_field('im_genre'); ?> </li>
<?php endif; ?>