Support » Themes and Templates » a different background for each category

  • viniciusmunich

    (@viniciusmunich)


    Hello again guys,
    A client of mine asked me for a variety of backgrounds were randomly displayed on your blog. I managed to do using php.

    Now she wants a particular background is displayed for each category / a different background for each category.

    I can not imagine how I can do that.

    Can anyone help me?

    Sorry for my english

Viewing 3 replies - 1 through 3 (of 3 total)
  • nicosFR

    (@nicosfr)

    I’ve done this already, but I don’t have the code right here.

    The idea is to have a php condition that detects which category you are in (search for get_the_category in the codex) and then load a CSS stylesheet that overrides your default background.

    esmi

    (@esmi)

    Forum Moderator

    If your theme’s header.php template file uses the body_class() function, each category will have a class based on the category name. You can then use this to apply different backgrounds via CSS.

    Hello,
    I found a question similar to mine in this post:
    http://wordpress.org/support/topic/different-background-color-for-different-categories?replies=5

    As you can see, you had success using this code:

    bgcolor="<?php
    foreach((get_the_category()) as $category) {
        echo $category->category_description  . ' ';
    }
    ?>"

    How and where should I use it?
    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘a different background for each category’ is closed to new replies.