How to Force Categories Widget to Display Empty Categories

Snippets by IsItWP

Do you want to display all categories with your categories widget even if they’re empty? By default, the WordPress categories widget doesn’t show empty categories. Add this snippet to the functions.php of your WordPress theme to display all categories with the default categories widget even if they’re empty.


All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

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

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: Best WordPress Page Builders (Compared).

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!