WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. vi_WP
    Member
    Posted 4 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 ?

    Vivien.

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

  2. Joshuwar
    Member
    Posted 4 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
    Member
    Posted 4 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
    Member
    Posted 4 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
    Member
    Posted 4 years ago #

    Thank you all!!!

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

    Vivien

  6. Joshuwar
    Member
    Posted 4 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