Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress

justinw
justinw
14,517 Points

Identify Wordpress Page in Inspector

I'm utilizing Firefox to inspect pages within my Wordpress site to know where to customize CSS within a theme that I'm using.

Right now, I'm struggling to identify which PHP page is being used when inspecting. Is there a way to identify this?

4 Answers

Hi Justin,

If you you have body_class set in the body tag you should see the template in use displayed as a class, e.g. page-template-default.

Failing that, for testing, I tend to drop a little text in to home.php, page.php, etc. so that if it displays on the page I can identify which is being used.

Hope that helps.

-Rich

Tim Knight
Tim Knight
28,888 Points

To add to Rich's suggestions if all else fails, sometimes I'll install a plugin called "What the File" which adds the name of the rendered template into the admin bar.

https://wordpress.org/plugins/what-the-file/

Good suggestion. Zac covered this in one of his videos (although it may have been one that has since been replaced with an updated version - can't remember which).

-Rich

Kevin Korte
Kevin Korte
28,135 Points

To echo Rich, I just drop in little comment at the beginning of the file so when you inspect in the developer mode, that comment will be in the markup.

justinw
justinw
14,517 Points

Guys this feedback is phenomenal. Thank you all so much for these informative responses.

No problem. Glad you found them useful :)

-Rich