Support

Account

Home Forums Add-ons Flexible Content Field Contract all flexible content fields by default

Solving

Contract all flexible content fields by default

  • I am looking to have all flexible content fields contracted (hidden) by default when visiting a page. Any help at all greatly appreciated

  • This reply has been marked as private.
  • Hi James,
    I’m also interested to know how to hide flexible content fields.
    Thanks.

  • Hi @bonjour

    I believe you can add a script to click the collapse button automatically when the page is loaded like this:

    add_action('acf/input/admin_head', 'my_acf_admin_head');
    function my_acf_admin_head() {
        
        ?>
        <script type="text/javascript">
        (function($) {
            
            $(document).ready(function(){
                
                $('.acf-field-flexible-content a.-collapse').click();
                
            });
            
        })(jQuery);    
        </script>
        <style type="text/css">
            
        </style>
        <?php    
        
    }

    I hope this helps 🙂

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

The topic ‘Contract all flexible content fields by default’ is closed to new replies.