It can be printed in the Html source code as follows:
add_action( 'wp_head', 'so_9405896_show_template', 999 ); function so_9405896_show_template() { global $template; echo ' <!-- TEMPLATE = ' . basename($template) .' --> '; }
Or to simplify the visualization, directly in the content with this:
add_filter( 'the_content', 'so_9405896_the_content_filter', 20, 1 ); function so_9405896_the_content_filter( $content ) { if( is_admin() || !current_user_can( 'administrator' ) ) return $content; global $template; $the_templ = '<strong style="background-color: #CCC;padding:10px">TEMPLATE = ' . basename( $template ) . '</strong><br />'; $content = sprintf( $the_templ . '%s', $content ); return $content; }
Result:

source share