I have this CSS setup for my blog posts meta information. But there are certain categories where I would like to use another image in the same spot and not display the meta information. I'm not quite sure how to do it.

.entry-meta {
background: url("images/dish_blogtitle.png") no-repeat scroll center center transparent;
color: #666666;
float: left;
font-size: 13px;
font-style: italic;
height: 100px;
line-height: 18px;
margin-left: -125px;
margin-top: 5px;
position: relative;
text-align: center;
top: -80px;
width: 100px;
  • does you theme use post_class() codex.wordpress.org/Function_Reference/post_class within the post div? if so, you could use the category dependant css classes as a basis for individual styles.
    – Michael
    Commented May 31, 2011 at 21:00
  • yes, I use them. I just didn't realize they were that powerful.
    – chris_s
    Commented May 31, 2011 at 21:45

2 Answers 2


Have you checked the classes on your <body> element?

It depends on the theme but WordPress has a function body_class() that dynamically adds a bunch of useful classes in there. It may look like this:

<body class="archive category category-news category-2 two-column content-sidebar">

As you can see it is a powerful helper as you can easily accomplish complex style changes by prepending your definitions with these classes. In your case it could be:

.category-something .entry-meta {
   /* whatever style changes you need */

If there is no such awesomeness in your <body> element then you can add it there yourself very easily:

<body <?php body_class(); ?>>

The answer provided by @xLRDxREVENGEx is certainly valid and points in the right direction. It's certainly worth (re)thinking what approach is the right one for your use case.

Hope this helps!


You are doing it write but you should think about looking into WordPress template hierarchy structure. Check out this page from the wordpress codex http://codex.wordpress.org/Template_Hierarchy

In your template folder create a file with category-slug.php or category-id.php

replace the slug word with the slug you assigned the category or put the id that is assigned to the category

  • another good solution. but the css route with custom body classes is less work for what I am trying to accomplish. thanks for the answer!
    – chris_s
    Commented May 31, 2011 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.