How can I list all pages with their templates?

I want to list all site pages with the template they use.

Is there a mod to wp_list_pages which does this?

4 Answers
4

https://codex.wordpress.org/Function_Reference/get_page_template_slug

a basic query to get all pages, sorted by title, then output page title and template file name:

$args = array(
    'post_type' => array( 'page' ),
    'order' => 'ASC',
    'orderby' => 'title'
    );
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
    while ( $the_query->have_posts() ) {
        $the_query->the_post();
        echo '<p>'; 
        the_title();
        echo ' - ';
        echo get_page_template_slug(); 
        echo '</p>';
    }
    wp_reset_postdata();
}

Leave a Comment