Support » Themes and Templates » Is this actually possible?

  • Kargo


    Hi guys, happy new year.

    My website is and as you can see, the TOP STORY block has a blue background with white text. It displays the most recent article, regardless of category. What I would like to do, if its even possible, is to have the blue background change to red if the post has been made in a certain category.

    For example,
    Category: Default = Blue Background
    Category: Special = Red Background

    I’m using the Playmaker theme, but this is the code. Is it possible to do this, adding something in the CSS?

    [Code moderated as per the Forum Rules. Please use the pastebin]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Michael


    Forum Moderator


    using post_class in the post div would certainly generate category dependant css class(es)



    Yup. The implementation section in the codex page that alchymyth has linked to has a very good example that should explain how to do it. If you need more help, feel free to ask and we can help you out further!



    Thank you everyone 🙂

    I’ve just read the codex and tried it out for myself but I seem to be getting a syntax error each time so I’m guessing ive done something wrong.

    here is the code of the ‘Top Story’ section that I’d like to change colour

    What would I need to add to the CSS? Just something like this?

    .category-79 {
    	background: #8b0000;
        color: #fafad2;
    	font-size: 22px;
    	line-height: 26px;
    <div class="topstory">

    this line here could be changed to:

    <div <?php post_class('topstory'); ?>>

    Which will keep your topstory class as I’m sure it’s used for styling, but will also get you optional classes including one like category-79 which you can style as you have suggested….but be specific enough in your css to only target that cat in that area….

    .topstory .category-79



    Thank you for posting ^

    I have added the code you suggested and it seems to work with no errors although the colours are still not showing.

    I added

    [CSS moderated as per the Forum Rules. Please post a link to your site instead.]

    but still its showing up the default blue when I post in the selected category. Am I doing something wrong?



    Apologies mods.

    I added the code above and the styling suggested to my CSS but still the colour isnt changing. Am I doing something wrong?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Is this actually possible?’ is closed to new replies.