Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress The WordPress Template Hierarchy Archive Templates in WordPress Category Archives

Carl Sergile
Carl Sergile
16,570 Points

In regards to the body class...

Can you name the class anything, just as you would if you were styling html with CSS or do you have to give the body a class in relations to the file name?

ex. body class="this_body_class" .this_body_class { color: blue; }

** picture the greater/less than sign around the body.

2 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

If I'm understanding your question correctly, body class isn't the same as a HTML class that you can target with CSS as such. It's a PHP function used in WordPress to add various setting to a website. To get to it, you'd simply add it like this

<body <?php body_class(); ?>>.

I don't quite know how it works but aparently it lets you add CSS styling to individual pages. Here's a little bit of info about the things you can do with it. :) http://wpshout.com/body_class/

Carl Sergile
Carl Sergile
16,570 Points

Okay this is a really good read. Like really good. So it pretty much helps you customize elements on the page depending on their id. What stops you from adding different classes to anything? I feel like with the example in the link you can then add this to the wp_header maybe? Since you are using add_filter(); ? Is this somewhat correct?