I'll try and make it brief. This snippet:

    get_pages(array(
        'meta_key' => '_wp_page_template',
        'meta_value' => 'page-news.php',
    ));

Is not behaving the same as the following:

    get_posts(array(
        'post_type' => 'page',
        'meta_key' => '_wp_page_template',
        'meta_value' => 'page-news.php',
    ));

The 2nd snippet returns the page I'm looking for, but without any hierarchal information.

What I'm trying to do is pull a page out that is using a specific template, including the $page->ancestors attribute.

If need be I can use get_ancestors() later, but it would be nice to have a $page object returned instead of the base $post.

I originally started out with this:

    $news_page = query_posts(array(
        'post_type' => 'page',
        'meta_key' => '_wp_page_template',
        'meta_value' => 'page-news.php',
        'meta_compare' => '=='
    ));

    return $news_page[0];

Even more confusion comes from the fact that the query returns the correct results with a template named page-contact-us.php and page-our-services.php, but not with several others including letterhead.php, page-our-services-sub.php or page-staff.php.

link|improve this question
Not exactly an answer, but I have run into the same thing- some templates work and some don't. For me, the templates that worked seemed to be the pages that had a parent page. When I changed the page to "no parent" it worked. I still cannot figure out the solution to getting a page with a parent and a specific template, but maybe someone out there can?? – alyssa Mar 1 at 21:46
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.