I encounter a problem with Advanced Custom Fields when I want to filter the results in the back office.
Here is my example, I have parent and child pages:

- Page 1
-- Subpage 1-1 [Template "Book"]
-- Subpage 1-2 [Template "Book"]
- Page 2
-- Subpage 2-1 [Template "Book"]
-- Subpage 2-2 [Template "Book"]
- Page 3 [Template "Book"]

And here is my code:

function my_post_object_query($args, $field, $post_id) {
    $args =  array(
            'post_type'   => 'page',
            'meta_query'  => array(
                'relation'  => 'AND',
                    'key'     => '_wp_page_template',
                    'value'   => 'templates/book.php',
                    'compare' => '='
    return $args;
add_filter('acf/fields/post_object/query/name=book_obj', 'my_post_object_query', 10, 3);

I have in my results only Page 3, basically, no child pages are displayed.
Do you know why?

Read more here: Advanced Custom Fields – Post Object: Query by page-template issue?


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: