How To Style Wordpress Categories Differently
Ever wanted a Tumblr-ish Wordpress site without resorting to a plugin or, God forbid, Tumblr?
You may notice on this blog I have different types of posts that display themselves with different styles. This isn’t unlike how a tumblelog [eg Tumblr.com] shows posts styled differently whether they are links or photos.
This is remarkably easy to do within Wordpress. The best thing is, you can alter styles for categories you add on the fly.
We do this using div tags. Here is the code you need to plug in where you would normally put the name of the div ID or class.
<div id="<?php $category = get_the_category(); echo $category[0]->cat_name; ?>">
This works for each post that calls a specific category and works best if you put posts into only one category. I’ve found you can post to two or three categories but it will choose, probably, the last div style in your stylesheet.
The step up from this is using Wordpress’ single.php templates to style each post by category when viewed on it’s own. If the category ID is 23, create a single-23.php file and go from there.
Tags: css, tech tip, tumblr, Wordpress