Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Show Empty Categories in WordPress Widgets

Do you want to show empty categories in WordPress widgets?

By default, the categories widget and block in WordPress don’t show categories that don’t have any posts assigned to them.

In this article, we’ll show you how to easily show empty categories in WordPress widgets or blocks.

Displaying empty categories in WordPress sidebar widgets and blocks

Why Show Empty Categories in WordPress?

By default, the WordPress categories widget or block doesn’t show empty categories.

Empty categories are categories that don’t currently have any posts assigned to them.

Empty categories with no posts

However, if you are in the middle of making a website, then you may need to show empty categories in sidebar widgets or elsewhere.

That being said, let’s take a look at how to easily display empty categories in your WordPress sidebar or block widgets.

Show Empty Categories in WordPress Widgets With a Shortcode

This method is flexible and works without affecting your default WordPress widgets or blocks.

It requires you to add code to your WordPress website. If you haven’t done this before, then check out our guide on how to add custom code snippets in WordPress.

First, you need to add the following code to your theme’s functions.php file or a site-specific plugin.

function wpb_list_categories() { 
// define category list parameneters
$args = array (
'echo'          => false,
'title_li'      => '',
'hide_empty'    => 0
// get categories list
$display_cats = wp_list_categories($args); 
//display custom categories list
return $display_cats; 
// create shortcode

This code simply adds a new shortcode that displays your category list and includes empty categories as well.

To use this, you need to add the shortcode widget or text widget to your WordPress sidebar.

In the widget settings, simply add the [custom_categories_list] shortcode and save your changes.

Shortcode widget

You can now go to your website to see your categories list in action.

It will display your empty categories as well as categories with posts.

Empty category displayed

You can also use this shortcode in your WordPress posts and pages.

Empty categories included in categories list

This method would also work if you are using older classic widgets on your website.

Simply add the shortcode to the text widget and save your changes.

Classic widgets

Method 2. Display Empty Categories in Classic Widgets

This method can be used if you have disabled block widgets and are using classic widgets on your WordPress website.

The advantage of this method is that instead of creating the shortcode, you can modify the behavior of the default category widget.

Simply add the following code to your theme’s functions.php file or a site-specific plugin.

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

After that, you can simply add the Categories widget to your sidebar and visit your website.

You’ll now see empty categories displayed in the categories list.

Empty category displayed

We hope this article helped you learn how to easily display empty categories in WordPress widgets. You may also want to see these handy WordPress tips, tricks, and hacks or take a look at our WordPress theme development cheat sheet for more ideas.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

6 CommentsLeave a Reply

  1. Hello and thank you. I tried this and it worked but I found out I was searching for something little different. You know when you set it the way that only one line is shown – when I set it that ways it still doen not show the empty cats. You know what I mean? If yes can you help? :)

    Best wishes from Germany, Cologne

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.