How to change the layout and styling of posts according to their category in WordPress?

I’m customizing a WordPress installation and was wondering what the best way to do this is. I want to customize each post completely depending on the category. Each post will be under only one category.

5 Answers
5

for the css route, you can use the post_class() function to give you category dependant css classes.

if you go beyond formatting, i.e. output different elements depending on the category, you could use the conditional tag in_category() in an ‘if-elseif-else’ structure.

the category archives can be done with category templates.

Leave a Comment