Is there a browser plugin or method to find which php template an item is coming from?
-
1What do you mean by "an item?" (More details in questions here almost always helps you get a better, quicker answer. Especially if you can explain your use-case with specifics.)– MikeSchinkelCommented Apr 6, 2011 at 4:12
-
possible duplicate of How do you find out which template page is serving the current page?– Michal MauCommented Jul 28, 2015 at 1:30
4 Answers
The Debug Bar together with the Debug-Bar-Extender will show you what template file is being used.
-
When I'm using a WP theme, there's various times when I see an embedded word or element and I want to know which php template it comes from. Commented Apr 6, 2011 at 21:56
-
@dreamgrowers: Ah, you are talking about just a snippet of HTML in the output? That is (almost?) impossible to figure out automatically, because they can come from anywhere: a template, your database, a generated string, some external data... I usually search my
wp-include
andwp-content
directory for a piece of a surrounding text (aclass
attribute for example), to pinpoint the most likely sources. Commented Apr 7, 2011 at 5:53 -
That's almost it. Although each area of the page is driven my a different template. How can I find out for a particular item or all items? Commented Apr 8, 2011 at 6:25
-
@dreamgrowers: This si very hard to do in a generic way. As AutoBLogged suggested, your best chance is to place a comment at the top and at the bottom of each template file, so you can look at the source code of the HTML page to find out where it comes from. Commented Apr 8, 2011 at 8:54
You could just add an HTML comment into each template file and then view source to see where the content you are trying to track down it is coming from.
-
Thats what I do to all my templates just to make it easier to track down weird template hierarchy issues.– Chris_OCommented Apr 6, 2011 at 7:42
the method I've been using is to find the item - such as a page title or whatever by using firebug extension for firefox. This will usually result in finding the related css class or id name for that item/element.
Then in dreamweaver I use the search function to find that class name from all of the files in the wordpress wp-content folder. Not sure of other programs like dreamweaver that have this search function but surely they exist.
I just wish there was a browser add on that would do for the php files what firebug does for css & html
The Query Monitor plugin is a very powerful tool for doing this. It shows the template and the queries and hooks the page generates; plus their load order, priority and whether it's core, parent theme, child theme or plugin. Very handle to have in your toolbox!
In WP Cli:
wp plugin install query-monitor --activate
On the repo: http://wordpress.org/plugins/query-monitor/