Is there a way to print a hierarchy of posts/pages/custom post types based on page template?
EG. I am often asked to review another web site and I’d like a way to ‘see’ all the pages that are assigned to the ‘Newsletter’ PHP template and all the pages assigned to the ‘Product Info’ PHP template.
Is there a plug-in like that or some code one can recommend?
To get all posts ordered by their template you need two functions: one for the query, and one to add a custom order.
Get the posts
Change the order
For a nice overview we could use something like this:
I am not sure in what context you need this but assigned page templates are kept in
$wpdb->postmeta
under the_wp_page_template
key so you can do something like …… to get your templates…
… to get posts to compare them against. They are associated by the
ID
==post_id
I suppose you could combine the two somewhat with…
You cannot get the automagically assigned templates this way, if that is what you need.