WordPress: Category Custom Styling

If you want to do some sophisticated styling of WordPress categories, this is a must-read:
Include the Category ID via postclass

For added goodness, here is a plugin that will show post, page, and category ID’s in your WordPress admin. Plus, you can designate what user levels are allowed to see them.

It’s called (drumroll…):  Reveal IDs for WP-Admin

A code snippet/tidbit for WordPress: You can have ‘current’ highlighted states for page items in a menu (“current_page_item”), but did you know there is a class in WordPress that you can use for current category items? It is called “current-cat” and here is an example of how to use it.

<?php if (is_category('CATEGORY-NAME') || in_category('#') && !is_home()) : ?> class="current-cat"<?php endif; ?>>

Translation: if this is the current category (referenced by name), and/or the current post belongs to that category (referenced by number), AND,(deep breath) it is NOT the home page, then highlight the link using the ‘current category’ class.

You can add the ‘current-cat’ class to your stylesheet and give it whatever color and background styling is appropriate for your theme.

There is a great plugin that will do this for you: Kahi’s Used Categories Plugin

I must be not getting enough sleep because I first thought it said “used cars plugin.” I am sure there is a plugin for that too. If not, I guess I should start writing it!

  • Share/Bookmark

You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or create a trackback from your own site.

There are no comments yet, be the first to say something


Leave a Reply

You must be logged in to post a comment.