Home Forums Backend Issues (wp-admin) Issue With Closing Flexible Fields by Default


Issue With Closing Flexible Fields by Default

  • Hello,

    I’m trying to close all flexible fields by default, so that when the edit page initially loads only the title of each flexible content layout is visible.

    I’m currently using this script:

    function my_acf_admin_head() {
    	<script type="text/javascript">
    	jQuery(document).ready(function($) {
    add_action('acf/input/admin_head', 'my_acf_admin_head');

    This does close all fields but it also closes fields that are then added to the page via the ‘Add Content’ button. Not sure why this is as I thought the above script would only run on initial page load?

    Any help greatly appreciated.



  • ACF includes a copy of layout that is uses to create a new layout by copying these. When you are setting the layouts to collapse you are also setting these copies.

    your selector should look something like this… I think, you may need to inspect the html to find them and target them, but this is the general idea

    $('.layout').not('.clones .layout').addClass('-collapsed');
  • Ah, that would explain it.

    Thanks for your help @hube2, appreciate it.

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

The topic ‘Issue With Closing Flexible Fields by Default’ is closed to new replies.