How to display empty categories in the category widget

By default, WordPress does not display empty categories in the category widget, but there are times when, especially as a developer, you need to display categories, even if they are “still” empty.

Well, it’s very easy to get categories to display in the widget, just add this code to your theme’s functions.php file or your customizations plugin:

/* Show empty categories in widget */ add_filter( 'widget_categories_args', 'wphelp_show_empty_categories' ); function wphelp_show_empty_categories($cat_args) { $cat_args['hide_empty'] = 0; return $cat_args; }
Code language: PHP (php)

When you save the changes you’ll go from this…

To this.

Read this post in Spanish: Cómo mostrar categorías vacías en el widget de categorías

How useful was this post?

Click on a smiley to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Skip to content