How to find the template your WordPress page is using

H

As in most things, there are many different ways to accomplish finding out what template or templates your page is using. Below we share a free plugin option and share a code snippet option for seeing what templates each page of your WordPress site uses.

Use a plugin to list the template files used on your WordPress pages

There are several free plugins that will list the templates used per page in a top admin bar for logged-in admin users. An example of one such plugin is Show Current Template by JOTAKI Taisuke.

Simple display of currently used WordPress template

The plugin adds the header “Template” to the top admin bar. The primary template is listed in the admin bar. For more details about what other templates are being accessed, simply hover over the Template area of the admin bar and you’ll see a full listing, such as shown below.

For more details about what other templates are being accessed, simply hover over the Template area of the admin bar and you'll see a full listing, such as shown in this image.
Displaying this page’s WordPress template hierarchy.

Add a PHP Snippet to WordPress to show admins the template being used

We like to use the plugin called Snippets (more useful code snippets) to add extra code to our WordPress site rather than adding the new code snippets directly to our functions.php file.

This PHP snippet checks if you’re a super admin and if you are, then displays the page’s template in the footer of your site for each page you visit. Public users do not see the page template listed in the footer. In this example, only one template file is shown. If you want a deeper dive, our suggestion is to use the Show Current Template plugin discussed above.

function show_loaded_template() {
	if ( is_super_admin() ) {
		global $template;
		echo 'The template used on this page is called: ';
		print_r( $template );
	}
}
add_action( 'wp_footer', 'show_loaded_template' );

We like to use the Snippets plugin to add code to our theme. Here’s a screenshot of how we added this show template code to our WordPress site.

The result of turning this code snippet on is that each page has text similar to the following on the bottom of the page (scroll down to the footer of your page).

About the author

Kelly Barkhurst

Designer to Fullstack is my place to geek out and to share tech solutions from my day-to-day as a designer, programmer, and business owner (portfolio). I also write on Arts and Bricks, a parenting blog and decal shop that embraces my family’s love of Art and LEGO bricks!

Add comment

By Kelly Barkhurst

Recent Posts

Archives

Categories