Hide Heading if ACF Field is empty
I am trying to add a Local FAQ section to all the individual location pages on a site with literally thousands of individual location pages. I am doing this by using ACF field in the custom post type. I've implemented this in a staging site. To give the local FAQ section a heading as opposed to there just being a list of questions answers, I added a h3 as seen below
h3 class=local_faq style=text-align: center; font-size: 50px;?php the_title(); ? Dumpster Rental FAQs/h3
However, since there are literally thousands of these pages, I want to implement this over time so I can still publish other changes I've made to the production site and therefore I don't want this h3 to be visible on pages that I haven't added any FAQs for yet.
Here's the full code for the local FAQ section:
h3 class=local_faq style=text-align: center; font-size: 50px;?php the_title(); ? Dumpster Rental FAQs/h3
div class=local_faq
?php if (get_field('local_faq')) : ?
?php while (the_repeater_field('local_faq')) : ?
div class=local_faq style=margin-left: 100px; margin-right: 100px;
h4
?php the_sub_field('question'); ?
/h4
p
?php the_sub_field('answer'); ?
/p
/div
?php endwhile; ?
?php endif; ?
/div
So, how do I hide the h3 if there aren't any FAQs entered yet?
Topic php custom-field theme-development Wordpress
Category Web