Wordpress Get Current Template

Posted onby admin


Jan 31, 2021 Another easy way to detect the WordPress theme used by a website is with IsItWP, a website theme detector. IsItWP is a free online tool that tells you the theme and plugins used by a WordPress website. Just open up the IsItWP website and enter the URL of the site you want to check. IsItWP will first check if the website is using WordPress. I spoke about this filter hook before in Get name of the current template file, but go grab a copy of that code and plonk it your theme's functions.php file. Then open up the theme's header.php or footer.php (or wherever you like) and use something like the following to print out the current template. To just get the current page template name, use the following line. Ispage AND print getpagetemplateslug( getqueriedobjectid ); File Name. When you just want to echo the current template file name, go with the following. Edit: Here's the new version of the plugin wrapped up in a class. It shows both the current. Get Current Page Slug WordPress There are several ways to get the current page’s or post’s slug in WordPress. Most simply, a post’s or page’s slug can be retrieved by accessing the global post object’s postname property.

A WordPress plugin which shows the current template file name, the current theme name and included template files’ name in the tool bar. If you like this plugin, you can buy me a coffee! 😉

Inspired by (and big thanks to):

  • https://gist.github.com/gatespace/4482529
  • https://wordpress.org/plugins/reveal-template/


The Good Way

  1. In your WordPress Admin, go to the Add New Plugins page
  2. Search for: Show Current Template
  3. Show Current Template should be the first result. Click the Install link.

The Old Way

  1. Upload the plugin to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress


I don’t see the toolbar.

Is the Toolbar (Show Toolbar when viewing site) option in your profile page is checked?
You can find your profile page is in your WordPress admin -> Users -> Profile.

I don’t see the current template file name in the toolbar.

Do you logged in as “Administrator”? Other role users like “Editor” can’t see the file name. If your WordPress is multisite, only super admin can see the file name.

Wordpress Get Current Template

I’dont think this plugin is working properly.

Please try below:

  • Activate one of the default themes.

Now the plugin work properly? Then it means there may be a compatibility issue between your theme and this plugin, so let me know your theme’s name and where I can get it.

  • Try to stop all plugins other than this plugin.

Wordpress Get Current Template Website

Now the plugin work properly? Then it means there may be a compatibility issue between one of those other plugins and this plugin, so let me know those plugins names and where I can get them.


Super simple plugin which works perfectly. One of my go to plugins for developing.

Get the specific template filename for a given post.


  • Related

Parameters Parameters


(intWP_Post)(Optional) Post ID or WP_Post object. Default is global $post.

Blog Templates Wordpress

Default value: null

Wordpress Get Current Page Id In Template

Return Return

(string false) Page template filename. Returns an empty string when the default page template is in use. Returns false if the post does not exist.

More Information More Information

The filename of a Page’s assigned custom template is stored as the value of a Custom Field with a key named '_wp_page_template' (in the wp_postmeta database table). If the template is stored in a Theme’s subdirectory (or a Parent Theme’s subdirectory of a Child Theme), the value of the wp_postmeta is both the folder and file names, e.g.

Wordpress Get Current Template Download

The function get_page_template_slug() returns an empty string when the value of '_wp_page_template' is either empty or 'default'.

Custom fields starting with an underscore do not display in the Edit screen’s Custom Fields module. To retrieve a Page’s custom template metadata, you can also use:

Source Source

File: wp-includes/post-template.php

View on Trac

Related Related

Wordpress get current page template slug

Uses Uses

Wordpress Get Current Template

Retrieves a post meta field for the given post ID.


Retrieves post data given a post ID or post object.