Dynamic CSS

  • Author
  • #42676


    I was wondering – if it’s possible through the custom css to set up a code that will change the bg image based on the following criteria:

    • Several Backgrounds customeized to specific categories.
    • Index page background would change based on the latest post’s categorey.
    • Single posts would have specific bgs based on categories.

    So basically, based on the category, the bg would change to that cat’s specified image.



    I’m hoping a techy type blogger will come along and help you as there is not staff support for css customization. I did find a thread in the forum search box that partly addresses one of your queries http://wordpress.com/forums/topic.php?id=5698&replies=6



    @3penny: Yes, I do that with my blog: http://engtech.wordpress.com

    Sandbox theme adds the categories to the body tag, so you could do CSS like:

    body.category-hello-world, body.s-category-hello-world {
    background: #fff url(‘blah.gif’) repeat top left;

    body.category-foo, body.s-category-foo {
    background: #fff url(‘blah2.gif’) repeat top left;


    hmm. that’s veeeeerrry interesting.

    thank you both for the advice. I’m rebuilding my blog as it is right now, but i’ll give this a shot when I upgrade it. I really hope that works.

    @ engtech, where is that applied? I’m took a cursory glance through your blog, but I didn’t notice anything in particular (except for the icons you’ve placed with your catagories…. v.cool) – how does the theme change? I’m going to go take a closer look now…



    @3penny: it’s the icons. :)

    but you could use the same method to change anything by category.

    For a while I had it so that any posts tagged with Christmas changed the cat to a picture of the cat in front of a christmas tree, but I kind of broke that when I added texture to the top header.

The topic ‘Dynamic CSS’ is closed to new replies.