If you use the Style theme from elegantthemes.com, and you want to have a custom background for different category, you will have to use some conditional formatting. This mean you have to edit the entry.php file and the syle.css file. Let’s take this and make an example.

So for our example let’s just say we have a wordpress category called Portfolio and we want to make the background for the label of this category green. Let’s start with the entry.php; locate this line:

  
  

and replace with:

  
  
">

What this line does is checking if a post is in a category with the slug portfolio and it will echo out portfolio-category so in this case if we have a post in the category Portfolio (this category will have by default a slug of portfolio) it will make the HTML code to become:

  
  

Now we can define our .portfolio-category in our style.css file. In the style.css you have only to find the rule for .category which is:

  
  div.category {
    background-color: #9a1d0d;
    display:block;
    position: absolute;
    top: 0px; right: 0px;
    padding: 8px 8px 3px 8px;
  }
  

and adapt this code for our newly created class portfolio-category so the last step is to add the following code to our style.css:

  
  div.portfolio-category{
    background-color: #9a1d0d;
    display:block;
    position: absolute;
    top: 0px; right: 0px;
    padding: 8px 8px 3px 8px;
  }
  

And that’s all you have to do. If you want to change multiple category this will require some bigger work, but I will return with some updates on this. So stay tuned.

About author

Young and dedicated fellow, which has playing with WordPress for 5 years now, likes everything about web design and web development.

View all author posts →

Share This