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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.