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

Click to rate this post!
[Total: 0 Average: 0]

Leave a Comment

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

Scroll to Top Skip to content