Skip to content

Instantly share code, notes, and snippets.

@maheshwaghmare
Created June 15, 2018 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maheshwaghmare/3bcfca0919a7d206679f0438c5b05196 to your computer and use it in GitHub Desktop.
Save maheshwaghmare/3bcfca0919a7d206679f0438c5b05196 to your computer and use it in GitHub Desktop.
Check which template loading in WordPress site.
<?php
/**
* 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>
</div>
<!-- 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;
}
</style>
<?php
}
add_action('wp_head', 'prefix_check_loaded_template');
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment