I am using the flexible content fields.
What I want to do is echo something on the frontend only if the subfield has a value.
I have no idea what is the correct PHP markup but in basic words something like below.
If the_sub_field(‘mysubfield’); has a value show <div class=”mysubfield”>the_sub_field(‘mysubfield’);</div>
Hope that makes sense=)
you need to use get_sub_field() to check a value. get_sub_field() returns a value and the_sub_field() echos the value.
if (get_sub_field('mysubfield')) {
?>
<div class="mysubfield"><?php the_sub_field('mysubfield'); ?></div>
<?php
}