Ready to get started?Download WordPress


How to get a specific post design for only one category (6 posts)

  1. vi_WP
    Posted 5 years ago #

    Hi everyone,
    I'd like to have a specific design for the posts of one category (no title, specific BG color, an icon at the beginning, etc. for instance).

    I don't know PHP, so I'm completely clueless. I couldn't find a tuto on the net.

    Anyone has suggestions ?


    P.S : Sorry for my frenglish.. ;-p

  2. Joshuwar
    Posted 5 years ago #

    Hey Vivien- I'd be interested to hear whether there's a way of doing that too. Meanwhile I've been achieving roughly the same result by using this rather excellent post template plugin, which works like using a single page template... Hope that helps in the interim..

  3. RGlover
    Posted 5 years ago #

    If you're using WP 2.7+ with a 2.7+ compatible theme, each post should be getting a class that includes the category into which it is placed. (e.g. category-uncategorized, category-pictures, category-tutorials, etc.) You can check to see if that is indeed the case by examining your index.php file and looking for <?php post_class(); ?> in the element in which the post is contained (typically a <div> element).

    If those things are true, and you're getting a category-x class for each of your posts, it should be a simple matter of adding the relevant CSS Styles to your stylesheet.

    Hope that helps.

  4. RGlover
    Posted 5 years ago #

    Another way I suppose you could do the job would be to use the in_category() method to test whether or not the_post() was in the category you want styled differently, and then output different HTML if that is the case, but it would seem a little excessive to do things that way, particularly as post_class() is already there, and targeting specific CSS styles seems like the faster and more effective option in the long run.

  5. vi_WP
    Posted 5 years ago #

    Thank you all!!!

    I'm going to test all that this WE and let you know.


  6. Joshuwar
    Posted 5 years ago #

    Excellent thanks RGlover- I'd not come across that tag- should be very useful.

Topic Closed

This topic has been closed to new replies.

About this Topic