If you ever played with WordPress theme files and tried to modify it by yourself, you probably already heard and learnt about the WordPress template hierarchy.
However, sometimes it’s hard to predict what template file is being used and loaded on the current page by just looking at the WordPress website frontend and the current page url. This can become even trickier if you are wrangling with a custom theme, made by someone else. Or, there might be specific plugins which hijack and override theme default template files. Yikes!
Show what template file is being used in WordPress
Luckily, there is a quick and easy way to find out the template being used. You can just add this little code snippet in your theme functions.php file:
1 2 3 4 5 6 7 8 9 10 11 12 | //For example, you can paste this into your theme functions.php file function meks_which_template_is_loaded() { if ( is_super_admin() ) { global $template; print_r( $template ); } } add_action( 'wp_footer', 'meks_which_template_is_loaded' ); |
That’s it! Make sure you are logged in, look at the very bottom of your website and you will see the path to the WordPress template file being loaded on the current page. Below is an example how it looks like on our own Meks website.
Detect which WordPress template file is currently being loaded (plugin solution)
While we personally prefer the above solution, as it is probably easier to just comment/uncomment this piece of code whenever you need it, there are a couple of plugins which may help you to achieve the similar thing.
Fell free to install and experiment with one of these plugins:
Thanks for sharing this, it’s exactly what i am searching for.
Thanks Meks..
Thanks Meks..
Simple article but it really helpful to us new in wordpress user.
keep posting.
Hi Meks,
I tried this code but it’s not working. The plugins that you recommended is it really working? I’m afraid that my site will break.
Waiting for your response.
Thanks!
Thanks for sharing informative blog about wordpress theme. as wordpress have free or paid theme but people become confused about which theme is useful for the wordpress website
Hey Meks,
I am New in Blogging, I have several doubts regarding WordPress free theme or paid theme. I am so confused, I have a low budget, So can you suggest me which theme is best for the blogging site my blogging niche is java development and programming.
Or else can you suggest me any web development company which helps me.
I am waiting for your response,.