List pages and templates
-
I want to display a list of pages and the template used by each.
The code I’m currently using is below, but the result is a bit verbose.
<?php global $wpdb; $sql = "SELECT post_title, meta_value FROM $wpdb->posts a JOIN $wpdb->postmeta b ON a.ID = b.post_id WHERE a.post_type = 'page' AND a.post_status = 'publish' AND b.meta_key = '_wp_page_template' "; $pages = $wpdb->get_results($sql); echo '<pre>'; print_r($pages); echo '</pre>'; ?>The output is…
[1] => stdClass Object ( [post_title] => Notes [meta_value] => default )I want to simplify it to something like…
[1] Notes => default
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘List pages and templates’ is closed to new replies.