Support

Account

Home Forums Feature Requests Filter for flexible content layouts Reply To: Filter for flexible content layouts

  • We tried lots of solutions here/there/anywhere and they didn’t work for us, we have a series of complex flex content fields and lots of custom post-types, not all layouts need to be used in all post types. We come out with this, maybe help someone:

    The basic idea is to hide the layout from the acf popup.
    This hides 3 layouts from the ACF Popup when you click ADD ROW in POSTS.

    
    function acf_flex_layouts_filter() {
    $type = get_post_type();
    if ($type=="post"): 
    ?>	
    <style>
       .acf-fc-popup a[data-layout='layout_name_1'] { display: none; };
       .acf-fc-popup a[data-layout='layout_name_3'] { display: none; };
       .acf-fc-popup a[data-layout='layout_name_8'] { display: none; };
    <style>
    <? 
    endif;
    }
    add_action('admin_head', 'acf_flex_layouts_filter');
    

    You adapt it to your needs.
    We created arrays with Layouts to hide for every post types:

    
    $hide_laypout['post'] = array( 'lay1','lay2,'lay3'...);
    $hide_laypout['page'] = array( 'lay8','lay9' ...);
    $hide_laypout['movie'] = array( 'lay7','lay3' ...);
    etc etc ...
    

    And loop then inside <style> </style>.

    Not sure if is the best solution but works for us.