list pages using page.php and NOT page-{slug}.php

I made a view templates for specific slugs

page1-220 use page.php
contact uses page-contact.php
service uses
page-service.php

Now I want to list the pages with their templates on a “overview” page with page-overview.php template… .

I tried this:

<?php $args = array(
‘post_type’ => ‘page’, /* or just ‘post’ */
‘posts_per_page’ => -1,

);
$the_query = new WP_Query( $args );
$i=1;
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo ‘<p>’;
echo $i . ‘. ‘;
the_title();
echo ‘ – ‘;
echo get_page_template();
echo ‘</p>’;
$i++;
}
wp_reset_postdata();
} ?>

get_page_template() allways returns the path to page-overview.php.

Wonder what I am missing here. I wonder if there is a way to get a list of ids, using the page.php template.

Many thanks in advance

Read more here:: list pages using page.php and NOT page-{slug}.php

Leave a Reply

Your email address will not be published. Required fields are marked *