Support

Account

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.