Force categories widget to display empty categories

As you may already know the wordpress categories widget does not provide the option to display empty categories. Adding this snippet to the functions.php of your wordpress theme will force the categories widget to display empty categories.

add_filter( 'widget_categories_args', 'force_widget_cat_args' );
function force_widget_cat_args($cat_args) {
    $cat_args['hide_empty'] = 0;
    return $cat_args;

Comments  Leave a Reply

  1. Thank you, thank you! I was about to modify the WordPress options / widgets file, but this is much neater. Probably saved me a ton of future time, too.

  2. thanks for code! i used it

  3. Its doesn’t work 🙁

    1.  Hi james, I just tested this in the most recent version of wordpress and works perfectly. Remember what this does exactly is display categories even if they are empty. However it does this for the sidebar widget, so if things are not working properly I would make sure you have the snippet placed within the functions.php correctly. Assuming this has been done you may have a plugin or other code within functions.php that is stopping this from working.

      I just tested this within the Twenty Eleven 1.1, that comes with wordpress.

  4. Perfect — been looking for hours for this fix — glad I found you. Thanks so much!

    1. No problem anytime.

  5. thanks..nice code…

    1. no problem anytime!

  6. Estetik fiyatlar? April 29, 2011 at 12:12 pm

    thanks for code

    1. No problem glad to hear you like the snippet!

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!