Skip to content

Instantly share code, notes, and snippets.

@chrisdigital
Created July 28, 2015 21:54
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 chrisdigital/a1264367998b8582b0d2 to your computer and use it in GitHub Desktop.
Save chrisdigital/a1264367998b8582b0d2 to your computer and use it in GitHub Desktop.
WordPress : How to find out the current template being used for current page
//http://www.wpinsite.com/code-snippets/how-to-get-the-name-of-the-current-wordpress-page-template
//https://wordpress.org/support/topic/get-name-of-page-template-on-a-page
/**
* Get the name of the current page template name.
* @return string
*/
function get_page_template_name() {
if(is_page()) {
global $post;
return str_replace('.php', '', get_post_meta($post->ID, '_wp_page_template', true));
}
return '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment