Skip to content

Instantly share code, notes, and snippets.

@theMikeD
Last active August 29, 2015 14:02
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 theMikeD/02c52b0a179e2e113a67 to your computer and use it in GitHub Desktop.
Save theMikeD/02c52b0a179e2e113a67 to your computer and use it in GitHub Desktop.
Function to insert the in-use template and page id into the document head as a comment. Aids in debugging.
add_action( 'wp_head', 'md_insert_template_info');
function md_insert_template_info() {
global $template;
global $post;
// get the path part
$url = parse_url($template, PHP_URL_PATH);
// split on /
$surl = explode('/',$url);
// template file is the last one
$tmpl = $surl[count($surl)-1];
// insert as commment
$out = "\n<!-- ----------------------------------------------------------\n\n" .
"\tTemplate: $tmpl\n" .
"\t Path: $url\n" .
"\t Page ID: " .
get_the_ID() .
"\n\n" .
"-------------------------------------------------------------- -->\n\n";
echo $out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment