Hack: Allow HTML In Category Descriptions

Last week I posted a hack that included category descriptions at the top of a category page. That works out great to be able to provide a description to the user about what they are looking at. But what if you wanted to include more than just plain text?

You’d think you’d be able to include HTML in a category description, and it would then show up. But it turns out that HTML is stripped from the category descriptions. How frustrating. But easy to fix. Just add this one line to your code in your functions.php file or custom plugin.

remove_filter('pre_term_description', 'wp_filter_kses');

Once this is present, you can now add HTML and it will stay in the description. I use this to put a small image icon with my description text that appears on those pages.

Leave a Reply

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