Adding HTML and Shortcode support to WordPress Category Descriptions

This is a guest article by Dan Harrison, who’s the director and chief developer for WordPress Doctors. Dan is also an experienced affiliate marketeer, focusing on eco and gadget niches.

Many of us spend a lot of time on our affiliate sites making them damn useful for our website visitors. That includes adding plenty of relevant and useful content. How many of you are adding descriptions to all of your categories? I expect quite a few of you are already doing it.

Are you frustrated by WordPress’s default behaviour of not permitting HTML in Category Descriptions? Do you want to add bold, images, perhaps even video to your categories? Well this article shows you how to fix that, plus another little trick for supporting WordPress shortcodes.

Adding HTML in Category Descriptions

This is a very simple fix, allowing HTML in category descriptions just requires you to add the following code to functions.php for your current theme:

$filters = array(‘pre_term_description’,

foreach ( $filters as $filter ) {
remove_filter($filter, ‘wp_filter_kses’);
remove_filter(‘term_description’, ‘wp_kses_data’);

That code basically tells WordPress not to strip out HTML when saving a category description. So now, HTML will work in your current theme.

HTML Categories description editing

HTML Categories description rendered

Adding Category Descriptions to your WordPress Theme

If you don’t already have category descriptions in your theme, then add the following code to your theme’s category.php. If you don’t have a functions.php file, then copy index.php to category.php, and make some tweaks.

. $category_description .


Adding Shortcode Support to Category Descriptions

If you don’t know what a WordPress shortcode is, it’s basically a word inside square brackets that looks a little like HTML, e.g. [example_shortcode /]. In WordPress it’s the best way to insert ‘stuff’ into the main content of a page by a plugin or theme. e.g. this might include inserting YouTube videos without having to insert the nasty embed code.

If you know what they are, then you might appreciate being able to add shortcodes to category descriptions. To add shortcode support, you just need to tweak the code for showing descriptions to the following, using WordPress’ do_shortcode() function:

. do_shortcode($category_description) .


HTML Categories with Shortcode editing

HTML Categories with Shortcode rendered


So there you go, some simple code that you can copy’n’paste into your WordPress theme to allow you to create pretty category descriptions. I hope you found that useful!

Please do post your examples in the comments below, we’d love to see what you’ve done with yours. Please only post 1 or 2 links in your comment though, so that the spam filter doesn’t automatically remove your comment.