Display current used page template WordPress

It is a bit confusing to locate a template when we are working with wordpress. Since there is no specific routing in wordpress for a custom built template file,It is time consuming to determine which template is using by current displaying page.There are different plugins to identify the current template file you are browsing in the front end.But it is not a good idea to always rely in the plugin for a small code snippet.

We can identify the current page template by two ways,

1.First way is to go to wp-includes/template-loader.php file.Then in that file add echo $template ; before  if ( $template = apply_filters( ‘template_include’, $template ) ) as shown below

Then in the top of fronted page you will see full path of current template file.

If you don’t see this in your front end page view your page source by pressing cnt + u then you will see this line at the top of the script.

Note : remove  echo $template ; from wp-includes/template-loader.phpwhen you are ready to live.

 

2.This is the second option .Copy and paste the following code to your function.php and you will see a block of current template name in the admin menu bar.

 

Comments

comments