Last active
August 29, 2015 14:02
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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