Created
December 29, 2015 15:31
-
-
Save mt3o/78d65901787888dd688c to your computer and use it in GitHub Desktop.
Print current wordpress template hierarchy.
This file contains hidden or 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
| <?php | |
| /** | |
| * Show template hierarchy and theme at the end of the request/page. | |
| * @return void | |
| */ | |
| function wpse31909_template_info() | |
| { | |
| // Don't display for non-admin users | |
| if ( ! current_user_can( 'manage_options' ) ) | |
| return; | |
| // You have to build yourself the hierarchy here or somewhere in front of the fn | |
| global $wp_template_hierarchy; | |
| $content = '<pre>'; | |
| // Show template hierarchy | |
| $content .= "TEMPLATE HIERARCHY\n==================\n"; | |
| $content .= var_export( $wp_template_hierarchy, true ); | |
| // Show current theme in use: | |
| $content .= "\n\nCURRENT THEME\n=============\n"; | |
| $content .= var_export( get_option( 'template' ), true ); | |
| // or: | |
| # $content .= var_export( get_template(), true ); | |
| $content .= '</pre>'; | |
| return print $content; | |
| } | |
| add_action( 'shutdown', 'wpse31909_template_info' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment