Support » Fixing WordPress » Is there a way to output debug info for the Template Hierarchy?

  • I want to display a list of theme files used to display any page I’m on. I need to see what combinations wordpress is using. I thinks I deleted some code by accident and it falling back to something else.. but I’m not sure what.
    I’m looking for something that is kinda like showing the database queries and load time.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi mrtaylor,

    There is a plugin that will show you the database queries and load time:

    I’m not sure if that will do exactly what you’re looking for, but it may help. This may help as well:

    My understanding of Template Hierarchy is that WordPress would only fall back to the next template file if the one it’s searching for isn’t there. If the file it’s looking for is coded improperly, then you should see an error.

    Hope this helps!

    I found this from Eric P at

    it generates an error on the first line of output.. then still gives me what I want.

    // this can live in /themes/mytheme/functions.php, or maybe as a dev plugin?
    function get_template_name () {
    	foreach ( debug_backtrace() as $called_file ) {
    		foreach ( $called_file as $index ) {
    			if ( !is_array($index[0]) AND strstr($index[0],'/themes/') AND !strstr($index[0],'footer.php') ) {
    				$template_file = $index[0] ;
    	$template_contents = file_get_contents($template_file) ;
    	preg_match_all("(Template Name:(.*)\n)siU",$template_contents,$template_name);
    	$template_name = trim($template_name[1][0]);
    	if ( !$template_name ) { $template_name = '(default)' ; }
    	$template_file = array_pop(explode('/themes/', basename($template_file)));
    	return $template_file . ' > '. $template_name ;

    with this for the footer:

    if (is_user_logged_in()) {
    	echo ' | '. get_template_name() ;

    I’m worried that I might have accidentally deleted some code that told it to look somewhere, no error would be generated.

    Hello again mrtaylor,

    What’s happening with your theme that makes you think it’s falling back to a different template file? Can you provide a link to your site?


    Sure! thanks for the help!
    I’m using the Under Construction plugin to hide it.
    My client doesn’t want it public until it’s ready.
    can you give me your IP address so I can add it to the whitelist?
    Or an email and I can give you the login. I checked out your profile.. helpful, prob not interested in hacking a tow truck website. 🙂


    actually.. try here:
    it’s the same website. I also have a local copy.. they are all the same at the moment. onlu site url in dashboard is different.

    I think I may have messed up something when I built Anythingslider into the child theme. It’s not the wordpress plugin.. it’s the javascript plugin with a custom loop for the slider itself. loop-slider.php
    The front page is supposed to be a static page.. but it’s showing loop-page with recent posts I think.
    maybe the slider loop has messed up the $query_string?
    I’m learning a lot by breaking and fixing things.. just got stuck on this one. The front page is supposed to have certain features.

    I’m going to keep posting as I work though this.. it might help someone else.

    if I’m running custom loops, or multiple loops I may have to reset the query: <?php wp_reset_query(); ?> to reset things. I think the front page is not being detected as the front page. I have several ` <?php if (is_front_page()):
    echo (‘this is the front page!’);
    endif; // if front page ?>` Most of them do something more useful, like the sidebar.. but they are not working.

    I just added <?php wp_reset_query(); ?> to the end of my loop-slider.php and the front page is back!
    note to self: rtfc (codex)

    These aren’t the droids your looking for.. move along.

    Hello again mrtaylor,

    Let me make sure I understand everything correctly.

    From your last post, it sounds like you were able to resolve this.

    If not, or you have issues in the future. If your have a copy of your files before adding in that slider, I would recommend reverting to that and then using this plugin to incorporate that slider into your child theme:

    Let me know how this goes for you.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Is there a way to output debug info for the Template Hierarchy?’ is closed to new replies.