Thanks John,it worked like a charm – I’ve created a multi-select field called “acf-user-schools” and added this:
function acf_load_user_school_field_choices( $field ) {
// reset choices
$field['choices'] = array();
// Get all the schools hierarchy ( Country -> District -> School )
$schools = getTaxonomyHierarchy( SCHOOLS_TAXONOMY );
// Get the children (all the districits) of USA
$schools = $schools [ USA ]->children;
if ( !empty( $schools ) AND !is_wp_error( $schools ) )
{
foreach( $schools as $district )
{
$field['choices'][ $district->term_id ] = $district->name;
}
}
return $field;
}
add_filter('acf/load_field/name=acf-user-schools', 'acf_load_user_school_field_choices');
Needed this today, and found the solution.
Here it is in case someone needs it:
function limit_cat_post_relationships( $title, $post3, $field, $post_id )
{
/* Because this is proccesd as an AJAX request
* we can get the referer, and extract the tag_ID from there
*/
$url = wp_get_referer();
$parts = parse_url($url);
parse_str($parts['query'], $query);
$title['tax_query'][0]['terms'][0] = $query['tag_ID'];
return $title;
}
add_filter('acf/fields/relationship/query/name=ibm_topic_feat_posts', 'limit_cat_post_relationships', 10, 3);