How to: List empty categories in WP category list

How to: List empty categories in WP category list

Basically, WordPress doesn’t list the empty categories in its category list. Then how to show empty categories in the 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 its value is TRUE. By this script, we are setting hide_empty‘s value as FALSE. So we can list empty categories with other categories.

Open your functions.php file and copy-paste this script. It’ll list 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 🙂