Get pages by template only works with some templates that have no parent
-
I have spent hours upon hours searching for this answer and I am about to rip my hair out!! It may be some kind of weird bug but I just want to make sure there’s nothing I’m doing wrong
So I have this
$pages = get_pages(array( 'meta_key' => '_wp_page_template', 'meta_value' => 'product.php' )); foreach($pages as $page){ echo $page->post_title.'<br />';
Which should return a list of page titles for my template product.php. But it doesn’t. So I played around and tried different templates- some worked and some didn’t.
Then I realized, all pages that have a parent page will not show up. When I changed one of the pages with the product.php template to “no parent”, that page displayed in my results.
I need these pages to have parent pages, so how can I display them by template?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Get pages by template only works with some templates that have no parent’ is closed to new replies.