How do you find out which template page is serving the current page?
When you activate a wordpress theme, it's always a hassle to find out which file to go to change things. Any idea how to simplify things?
But on the other hand, considering the get_template_part functionality, this may be impossible. What do you say?
View the source code and look for the body classes which tell you which template is used. Also gives you the i.d.
template_include, set a global to note the template set by the theme then read that value back into the footer or header to see which template is being called for a given view.
Then open up the theme's
footer.php(or wherever you like) and use something like the following to print out the current template.
<div><strong>Current template:</strong> <?php get_current_template( true ); ?></div>
If you wanted to use this on a production site and keep that info away from your non-administrator users, add a little conditional logic.
<?php // If the current user can manage options(ie. an admin) if( current_user_can( 'manage_options' ) ) // Print the saved global printf( '<div><strong>Current template:</strong> %s</div>', get_current_template() ); ?>
Now you can keep track of what views are using what template, whilst keeping that info away from your visitors.
If there is something wrong with this answer, or if anyone could provide comments on what could be done to improve this answer, have at it, drop a comment here and share your thoughts and ideas on how to make it better.