Home › Forums › ACF PRO › Get the settings of all fields saved on a specific post type › Reply To: Get the settings of all fields saved on a specific post type
Hey,
I solve my topic with this script (which I do not find optimal)
$fields_groups = get_posts(array(
'post_type' => 'acf-field-group',
'posts_per_page' => -1,
));
$fields_groups = array_filter($fields_groups, function($group){
$regex = '/i:\d;a:1:{i:0;a:3:{s:5:"param";s:9:"post_type";s:8:"operator";s:2:"==";s:5:"value";s:7:"product";}}/';
return preg_match($regex, $group->post_content);
});
$fields_groups = array_map(function($group){
return $group->ID;
}, $fields_groups);
$fields = get_posts(array(
'post_type' => 'acf-field',
'post_parent__in' => $fields_groups,
'posts_per_page' => -1,
));
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.