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?
Hook onto 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.
I spoke about this filter hook before in Get name of the current template file, but go grab a copy of that code and plonk it your theme’s functions.php
file.
Then open up the theme’s header.php
or 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.