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
The topic ‘The body_class function’ is closed to new replies.