Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is there a browser plugin or method to find which php template an item is coming from?

share|improve this question
1  
What 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.) –  MikeSchinkel Apr 6 '11 at 4:12

3 Answers 3

up vote 4 down vote accepted

The Debug Bar together with the Debug-Bar-Extender will show you what template file is being used.

Debug Bar Extender showing the query template

share|improve this answer
    
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. –  dreamgrowers Apr 6 '11 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 and wp-content directory for a piece of a surrounding text (a class attribute for example), to pinpoint the most likely sources. –  Jan Fabry Apr 7 '11 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? –  dreamgrowers Apr 8 '11 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. –  Jan Fabry Apr 8 '11 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.

share|improve this answer
    
Thats what I do to all my templates just to make it easier to track down weird template hierarchy issues. –  Chris_O Apr 6 '11 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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.