Unique Post Template For Each Category? (3 posts)

  1. Joe Hall
    Posted 6 years ago #

    Hi there! I am trying to create a post template for post in a certain category. In other words, when a user opens a post's permalink they get a different layout/template if the post is in a certain category.

    I have already looked at the Category Template page, and it appears that is only for category archives.

    I have considered using a conditional tag, but doing so seems a bit excessive use of code.

    Is there any other solutions?

  2. Mark Ratledge
    Forum Moderator
    Posted 6 years ago #

    This is not what you want from the Category Template doc?:

    So, if you want to make the Category whose ID number is 6 look different from what it is currently (and different from other Category pages), you would want to create a category-6.php file. If you want to make all Category pages look different from other archive pages (such as date and author archives), then you would want to create or modify the category.php file.

    Possibly along with a conditional tag to select a different style sheet for each category?

  3. Peter Boosten
    Posted 6 years ago #

    Every post has an extra ID attached to it, called category-<yourcategoryname>

    I'm sure you can do something with that.


Topic Closed

This topic has been closed to new replies.

About this Topic