Skip to content

Instantly share code, notes, and snippets.

@pbowyer
Last active August 29, 2015 13:57
Show Gist options
  • Save pbowyer/9766002 to your computer and use it in GitHub Desktop.
Save pbowyer/9766002 to your computer and use it in GitHub Desktop.
To show where one Wordpress template begins and another finishes, open wp-includes/template.php and replace function `load_template` with the one below. Then add the contents of `functions.php` to the end of your theme's custom functions file.
<?php
add_filter( 'template_include', 'mysite_template_include', 1000 );
function mysite_template_include( $template ){
$comment_template = str_replace(array(TEMPLATEPATH, STYLESHEETPATH), '', $template);
echo "<!-- Template: $comment_template -->\n";
include( $template );
echo "<!-- End Template: $comment_template -->\n";
return false;
}
<?php
function load_template( $_template_file, $require_once = true ) {
global $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
if ( is_array( $wp_query->query_vars ) )
extract( $wp_query->query_vars, EXTR_SKIP );
$comment_template_file = str_replace(array(TEMPLATEPATH, STYLESHEETPATH), '', $_template_file);
echo "<!-- Template: $comment_template_file -->";
if ( $require_once )
require_once( $_template_file );
else
require( $_template_file );
echo "<!-- End Template: $comment_template_file -->";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment