0

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?

Thanks.

4
  • what theme are you using? does the theme use post_class()?
    – Michael
    Commented Feb 14, 2013 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... Commented Feb 14, 2013 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
    Commented Feb 14, 2013 at 16:45
  • Any idea on what CSS I need to add? I'm getting myself very confused! Thanks. Commented Feb 14, 2013 at 17:02

1 Answer 1

0

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:

<?php
// 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>';
2
  • That's great thanks. How do I create the CSS for it? Sorry, I'm trying to learn as I go along here! Commented Feb 14, 2013 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;} } Commented Feb 14, 2013 at 16:45

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.