I have some fields which I only wish to show if the fields are not blank.
My code so far…
<a href="<?php the_field('field_link'); ?>"><img src="<?php the_field('field_image'); ?>"></a>
This works fine if someone has entered a value for both the link and image.
Is it possible to not display anything if the fields are blank?
I have tried various configurations to make this work with my above code and can’t get it to work.
Wrap the link and image inside of an if, which checks to see if both are not empty like this:
<?php if ( get_field(‘field_link’) != “” && get_field(field_image) != “” ) { ?>
“>“>
<?php } ?>