A custom sidebar for WordPress that works with posts too

OK, so last week I put up a nice bit of code that would like you add a custom sidebar based on your current category but there was a pretty big problem with it … the custom sidebar only worked while looking at the category page (the category.php), not a post within that category.

Here’s a new piece of code that not only looks to see what category you’re in while looking at the category page but also within a post.

There is one shortcoming on this script. If you put a post in multiple categories, the script has no way of determining which category you think should be the primary category, and instead sets your category to the first.

Leave a Reply

Your email address will not be published. Required fields are marked *