Check which template loading in WordPress site


Below is the simple function which you can use for debugging the site. It  display the template file path of the current page. Like below image:

Add below code snippet into your themes functions.php file.

* Check Which Template Loading
* @todo Change the `prefix_` from function name with your own prefix.
* @since 1.0.0
if( ! function_exists( 'prefix_check_loaded_template' ) ) :
function prefix_check_loaded_template()
// This global variable contain the currently loaded template file path.
global $template;
<div class="loaded-page-template">
<h3><?php _e( 'Template File:', 'prefix' ); ?></h3>
<p><?php echo esc_url( $template ); ?></p>
<!– SKIP the styling. Just for reference. –>
<style type="text/css">
.loaded-page-template {
position: fixed;
right: 0;
top: 0;
z-index: 99999999999;
background: #FFEB3B;
padding: 15px 20px;
.loaded-page-template h3 {
margin-bottom: 10px;
font-weight: bold;
.loaded-page-template p {
margin-bottom: 0;
add_action('wp_head', 'prefix_check_loaded_template');

%d bloggers like this: