WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For my category titled 'mindset' I would like to use the following style on my post header:

background: none repeat scroll 0 0 grey;
border-bottom: 5px solid #83990A;

However for my 'news' category I would like to use the following style:

background: none repeat scroll 0 0 grey;

Any ideas of the coding I could use?


share|improve this question
what theme are you using? does the theme use post_class()? – Michael Feb 14 '13 at 14:44
Michael I'm using a theme called Sevent - tried to get support through them, but sadly to no avail. Not sure if it uses that... – thestealthyfox Feb 14 '13 at 16:36
unfortunately your theme does not seem to use post_class() - so following the suggestion by @Max Yudin is possibly a way to go. – Michael Feb 14 '13 at 16:45
Any idea on what CSS I need to add? I'm getting myself very confused! Thanks. – thestealthyfox Feb 14 '13 at 17:02

I assume that any post belongs to only one category.

Create respective CSS classes, e.g. 'news-header' and 'mindset-header', and use following code inside the loop:

// get post categories
$categories = get_the_category();
// get single category
$category = $categories[0];
// echo header with category class
echo '<h2 class="' . $category . '-header">' . get_the_title() . '</h2>';
share|improve this answer
That's great thanks. How do I create the CSS for it? Sorry, I'm trying to learn as I go along here! – thestealthyfox Feb 14 '13 at 16:34
For example my current CSS that covers all post titles is: .blog-entry h4 a {font-size:18px !important; color:#ffffff !important; margin-left: 5px !important;} .blog-entry h4 { background: none repeat scroll 0 0 grey; border-bottom: 5px solid #83990A; font-size: 18px !important; line-height: 35px !important; margin-bottom: 0 !important;} } – thestealthyfox Feb 14 '13 at 16:45

Your Answer


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.