How to: List empty categories in WP category list

Basically, WordPress doesn’t lists the empty categories in it’s category list. Then how to show empty categories in category list?. In this note I’d like to share a simple script for this problem.

In WP, we’re using wp_list_categories() to lists the categories. There is an argument in this function called hide_empty, by default it’s value is TRUE. By this script, we are setting hide_empty‘s value as FALSE. So we can lists empty categories with other categories.

Open your functions.php file and copy paste this script. It’ll lists your empty categories.

function all_cates($args)
 $args['hide_empty'] = 0;
 // you can override any other defaults here too
 return $args;
 add_filter( 'widget_categories_args', 'all_cates' );

This script was successfully tested in WordPress 3.2.1. if you like to know more about wp_list_categories() check out WP Codex. Happy blogging 🙂