Having trouble tracking down which theme template file is outputting the current page’s content?

Here’s a simple hook you can throw in your functions.php file to save you some time and headaches!

add_action('wp_head', 'show_template');
function show_template() {
    global $template;
    if (current_user_can('administrator')) echo basename($template);
}

Notice we added a check to make sure the visitor is logged in with administrator privileges. If this is on a development site, just omit the if condition if you don’t want to have to be logged in to see the filename.

Hope that helps!

Allen Robinson

Director of Application Development
Allen has been responsible for overseeing client website development, implementation, and maintenance at Foxtrot Media for over 10 years. A Computer Science graduate from the University of Wisconsin- Madison, Robinson is a software development and content management system specialist, fluent in CSS, PHP, MySQL, HTML, and JavaScript.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Allen Robinson

Director of Application Development
Allen has been responsible for overseeing client website development, implementation, and maintenance at Foxtrot Media for over 10 years. A Computer Science graduate from the University of Wisconsin- Madison, Robinson is a software development and content management system specialist, fluent in CSS, PHP, MySQL, HTML, and JavaScript.

Post Details

Categories:

Related Articles