Title: The body_class function
Last modified: August 19, 2016

---

# The body_class function

 *  Resolved [HMW666](https://wordpress.org/support/users/hmw666/)
 * (@hmw666)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/the-body_class-function/)
 * Hi!
 * I am pretty new to WP. I know xhtml & CSS though. At first it took me a while
   to get used to all the php codes and the whole structure of WP, now I think it’s
   kind of fun, and a cool way to build websites.
 * Anyway, coming from the world of ”classic” CSS/xhtml approach – I felt (and to
   some extent still do) ”locked in” by the templates. It’s great that they are 
   there, but they can also prove a bit difficult to modify.
 * I just discovered (much to my delight) the body_class function, which allows 
   me to set different backgrounds per page (amongst other things). I used the function
   to set a different background for a specifik div on a page, like so:
 *     ```
       .page-id-34 #wrapper
       {
       	 background-image: url('images/test.jpg');
       }
       ```
   
 * It worked fine, which was great. So now I wanted to move on to some other pages
   with the exact same approach/picture, but it’s (for some reason) a no-go. My 
   little code-snippet looks like this:
 *     ```
       .page-id-34 #wrapper
       {
       	 background-image: url('images/test.jpg');
       }
   
       .page-id-37 #wrapper
       {
       	background-image: url('images/test.jpg');
       }
       ```
   
 * To sum it up, it works for page 34, but not for page 37 – which strikes me as
   odd. If someone could point out where the error might be, I’d appreciate it.
 * Thanks for reading this,
 * HMW666

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/the-body_class-function/#post-2037005)
 * link to your site?
 * have you cleared the browser cache?
    (‘CTRL F5’)
 *  Thread Starter [HMW666](https://wordpress.org/support/users/hmw666/)
 * (@hmw666)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/the-body_class-function/#post-2037109)
 * Thank you for your reply. The site in question is for a friend of mine, I am 
   not sure he want it to be ”public” at this point.
 * Yes, I have cleared the cache, and tried it in both FF & Chromium – but still
   no cigar.
 * The page that does not work is the ”blog” page, might that have something to 
   do with it? The page where it works is a ”static” one.
 * Thanks again!
 * HMW666
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/the-body_class-function/#post-2037125)
 * you can get the blog page with the css class `.blog` or
    `body.blog`
 * (you are right, it does not output `.page-id-77`)
 * (i quick look into the html code of the blog page in the browser could have shown
   you the body_classes)
 *  Thread Starter [HMW666](https://wordpress.org/support/users/hmw666/)
 * (@hmw666)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/the-body_class-function/#post-2037212)
 * Right on dude!
 * Thanks, you’re right. For the life of me I don’t know why I didn’t check the 
   source code for the body class, that’s how I found the #wrapper div I was looking
   for in the first place!
 * Thanks for your help alcymyth, I appreciate it!
 * Best,
 * HMW666

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘The body_class function’ is closed to new replies.

## Tags

 * [body_class](https://wordpress.org/support/topic-tag/body_class/)

 * 4 replies
 * 2 participants
 * Last reply from: [HMW666](https://wordpress.org/support/users/hmw666/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/the-body_class-function/#post-2037212)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
