I am trying to filter the pages listed on the post object field to display only pages that are in an array.
I managed to get it to work using a relationship field. However, i need to make a reverse query and need to use the post object field.
This is the code is used for the relationship field query filter
function my_relationship_query( $args, $field, $post )
{
// increase the posts per page
$args['post__in'] = array(32,14); //works!
return $args;
}
// filter for a specific field based on it's name
add_filter('acf/fields/relationship/query/name=where_used','my_relationship_query', 10, 3);
And here is the code I tried to use for the post object query which no matter what i do or change it does not change the results in the dropdown (all pages are always listed in the dropdown).
function my_post_object_query( $args, $field, $post_id ) {
// only show children of the current post being edited
$args['post__in'] = array(32,14);;
// return
return $args;
}
// filter for a specific field based on it's name
add_filter('acf/fields/post_object/query/name=where_used', 'my_post_object_query', 10, 3);
Thanks in advance for your help
Paul
function my_relationship_query( $args, $field, $post ) {
// only show children of the current post being edited
$args['post_parent'] = $post->ID;
return $args;
}
// filter for every field
add_filter('acf/fields/relationship/query/name=relationship_field_name', 'my_relationship_query', 10, 3);