Home Forums Add-ons Repeater Field Hide repeater field entry with ACF checkbox


Hide repeater field entry with ACF checkbox

  • I’ve got a repeater field and have added a checkbox to allow site editors to check the box to say they want that particular repeater field entry/block to be hidden on the website.

    Then in my theme, I have this PHP code to add ‘display: none’ if the site editor checks the ‘hidden’ checkbox.

    <?php $checked = get_sub_field('hide'); if( $checked && in_array('Yes, hide.', $checked) ) { ?>style="display: none;"<?php } ?>

    This works fine and hides the content if they check the box. The problem is that the WordPress search results excerpts still display the ‘hidden’ content. I get why – because display: none, allows the content to still be in the page source.

    So – how would I go about removing a repeater field entry/bock from the page source if site editors check the box saying it should be hidden?

  • Normally, ACF field values are not included in the excerpt because the values are not added to post_content. You must be doing something else, some code or have another plugin that allows this to happen in the first place.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.