Home › Forums › General Issues › Get main group from sub clone field › Reply To: Get main group from sub clone field
Yes, for the moment i get the parent field from root group and i go through its children :
add_filter( 'acf/get_fields', 'acf_get_fields', 10, 2 );
function acf_get_fields( $fields, $parent ) {
if ( $parent['key'] === 'group1' ) {
foreach ( $fields as &$field ) {
if ( $field['name'] === 'my_parent_field' ) {
foreach ( $field['sub_fields'] as $k => &$sub_field ) {
if ( $sub_field['name'] === 'my_target_field' ) {
// my code
}
}
}
}
}
return $fields;
}
But it would be great if acf_get_field_ancestors works with clone fields 🙂
Sadly, i looked at the source code and apparently, it could takes a lot of work.
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.