Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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;
}
share|improve this question
    
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 May 31 '11 at 21:00
    
yes, I use them. I just didn't realize they were that powerful. –  chris_s May 31 '11 at 21:45
add comment

2 Answers

up vote 4 down vote accepted

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!

share|improve this answer
    
exactly what I was looking for. thank you maugly. –  chris_s May 31 '11 at 21:34
    
Nice! You're welcome! –  Michal Mau May 31 '11 at 21:53
add comment

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

share|improve this answer
    
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 May 31 '11 at 21:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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