Skip to main content
3 of 7
added 12 characters in body
kaiser
  • 50.8k
  • 27
  • 150
  • 244

An addition (more sweet code) to other answers here.

Template Name

To just get the current page template name, use the following line.

is_page() AND print get_page_template_slug( get_queried_object_id() );

File Name

When you just want to echo the current template file name got with the following

is_page() AND print basename( $GLOBALS['template'] );

No need to hook into template_redirect as the global is already setup in a template file.

kaiser
  • 50.8k
  • 27
  • 150
  • 244