为什么这个get_pages返回一个空数组?

I'm trying to add a meta box for my custom post type (which is inside a plugin).

I want to get all pages that are assigned a particular page template in my Wordpress site, so I use the following:

$surgeons = get_pages(array(
    'meta_key' => '_wp_page_template',
    'meta_value' => 'template-meet-the-team-single.php'
));

However, $surgeons is returned as an empty array, why?

It sounds like no page is using the template I'm stating, as if I just use the default get_pages() it returns all pages, but this is incorrect as I definitely have pages that are assigned this template.

Does it matter that this code is in a plugin file, and the meta_value is trying to locate this template in the plugin folder?

Although I don't think this really provides an answer to the issue I Was having, this was the way to fix the array being returned and provide the correct results.

Instead of using get_pages(), I simply switched it to get_posts(), which then returned the correct results.

$surgeons = get_posts(array(
    'post_type' => 'page',
    'posts_per_page' => -1,
    'meta_key' => '_wp_page_template',
    'meta_value' => 'template-meet-the-team-single.php'
));

Please try by using custom query:

$all_team_single =  query_posts(array(
        'post_type' =>'page',
        'meta_key'  =>'_wp_page_template',
        'meta_value'=>'template-meet-the-team-single.php',
    ));

Your above code looking fine , to get more help please visit the below link. https://wordpress.stackexchange.com/questions/173469/loop-through-pages-with-specific-template