I am building a site where we are relying on the post categories to help drive some of the site organization and architecture. This has made organizing the site easier, but presented a couple of new challenges. I wanted to use the built in Category description field to provide content for the ‘pages’ that display all the posts in that category.
This was pretty easy to accomplish by adding the following code to the right place in my category.php file:
In order to provide navigation to each category I wanted to use the built in WordPress category widget (no sense in reinventing the wheel). Drop it in and go, simple enough. But wait, on the page where I display all my categories, I want to use the featured image of a single posts within the category that also has the category of “Featured”. I did not want this featured category to show up in that WordPress category widget I was using as navigation. This was a simple fix using WordPress filters. I added this to my functions.php file:
$exclude = "1"; // The IDs of the excluding categories
$args["exclude"] = $exclude;
Great! Now Featured doesn’t show up, but one last problem. The descriptions I am using on my category.php file are showing up as link
title attributes which bring up a huge ugly yellow box when the user hovers over the link. I didn’t have much luck googling for this one, but it turns out it is an easy fix because there is another
arg we can add to our
widget_categories_args filter function:
$args["use_desc_for_title"] = 0;
There that should do it for our category description integration.