Can someone please look at this code and let me know where I am going wrong? I have been using this code for at least two years and for some reason, it has just stopped working properly.
Here is my set up in ACF Pro (latest version):
I have a Group and within the group, 3 sub-fields (see image for the names, etc). These are set to show on both post type page and my option pages (which are set up in functions.php as option, option2, option3).
My issue is that my div cta_wrap is showing up even when there is no content entered in that custom field on the page. I’ve gone one step further and even made sure that none of the pages have anything in that custom field. I am sure it’s something simple but please, help my tired brain!
<?php global $post; if ( get_field('page_heading', $post->ID ) ): ?>
<div id="cta_wrap" />
<?php echo $post->ID; ?>
</div>
<?php endif; // endif is home page ?>
I have also tried
<?php global $post; if ( have_rows('page_heading', $post->ID ) ): while(have_rows('page_heading', $post->ID) ): the_row(); ?>
<div id="cta_wrap2" />
<?php echo $post->ID; ?>
</div>
<?php endwhile; endif; // endif is home page ?>
and
<?php global $post; if ( have_rows('page_heading', $post->ID ) ): the_row(); ?>
<div id="cta_wrap2" />
<?php echo $post->ID; ?>
</div>
<?php endif; // endif is home page ?>
NOTE: Here is a screenshot of my setup