Home › Forums › General Issues › How to check if field group exists in ACF5/Pro › Reply To: How to check if field group exists in ACF5/Pro
Thanks Daron it did give me an idea.
Here what I come up with the idea.
function is_field_group_exists($value, $type='post_title') {
$exists = false;
if ($field_groups = get_posts(array('post_type'=>'acf-field-group'))) {
foreach ($field_groups as $field_group) {
if ($field_group->$type == $value) {
$exists = true;
}
}
}
return $exists;
}
Anyone can use the function for checking if field group exist.
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.