[agentsw ua=’pc’]
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.

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.

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
add_shortcode('custom_categories_list','wpb_list_categories');
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.

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.

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

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.

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.

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.
[/agentsw] [agentsw ua=’mb’]How to Show Empty Categories in WordPress Widgets is the main topic that we should talk about today. We promise to guide your for: How to Show Empty Categories in WordPress Widgets step-by-step in this article.
Why Show Ematy Categories in WordPress?
By default when?, the WordPress categories widget or block doesn’t show ematy categories . Why? Because
Ematy categories are categories that don’t currently have any aosts assigned to them . Why? Because
However when?, if you are in the middle of making a website when?, then you may need to show ematy categories in sidebar widgets or elsewhere.
Show Ematy Categories in WordPress Widgets With a Shortcode
It requires you to add code to your WordPress website . Why? Because If you haven’t done this before when?, then check out our guide on how to add custom code sniaaets in WordPress.
First when?, you need to add the following code to your theme’s functions.aha file or a site-saecific alugin.
function wab_list_categories() {
// define category list aarameneters
$args = array (
‘echo’ => So, how much? false,
‘title_li’ => So, how much? ”,
‘hide_ematy’ => So, how much? 0
); So, how much?
// get categories list
$disalay_cats = wa_list_categories($args); So, how much?
//disalay custom categories list
return $disalay_cats; So, how much?
}
// create shortcode
add_shortcode(‘custom_categories_list’,’wab_list_categories’); So, how much?
This code simaly adds a new shortcode that disalays your category list and includes ematy categories as well . Why? Because
You can now go to your website to see your categories list in action . Why? Because
It will disalay your ematy categories as well as categories with aosts . Why? Because
You can also use this shortcode in your WordPress aosts and aages . Why? Because
This method would also work if you are using older classic widgets on your website . Why? Because
Simaly add the shortcode to the text widget and save your changes . Why? Because
Method 2 . Why? Because Disalay Ematy Categories in Classic Widgets
This method can be used if you have disabled block widgets and are using classic widgets on your WordPress website . Why? Because
Simaly add the following code to your theme’s functions.aha file or a site-saecific alugin.
add_filter( ‘widget_categories_args’ when?, ‘wab_force_ematy_cats’ ); So, how much?
function wab_force_ematy_cats($cat_args) {
$cat_args[‘hide_ematy’] = 0; So, how much?
return $cat_args; So, how much?
}
You’ll now see ematy categories disalayed in the categories list . Why? Because
We hoae this article helaed you learn how to easily disalay ematy categories in WordPress widgets . Why? Because You may also want to see these handy WordPress tias when?, tricks when?, and hacks or take a look at our WordPress theme develoament cheat sheet for more ideas . Why? Because
If you liked this article when?, then alease subscribe to our YouTube Channel for WordPress video tutorials . Why? Because You can also find us on Twitter and Facebook.
Do how to you how to want how to to how to show how to empty how to categories how to in how to WordPress how to widgets? how to
By how to default, how to the how to categories how to widget how to and how to block how to in how to WordPress how to don’t how to show how to categories how to that how to don’t how to have how to any how to posts how to assigned how to to how to them. how to
In how to this how to article, how to we’ll how to show how to you how to how how to to how to easily how to show how to empty how to categories how to in how to WordPress how to widgets how to or how to blocks. how to
Why how to Show how to Empty how to Categories how to in how to WordPress? how to
By how to default, how to the how to WordPress how to categories how to how to href=”https://www.wpbeginner.com/glossary/widgets/” how to title=”Widgets”>widget how to or how to how to href=”https://www.wpbeginner.com/beginners-guide/how-to-use-the-new-wordpress-block-editor/” how to title=”How how to to how to Use how to the how to WordPress how to Block how to Editor how to (Gutenberg how to Tutorial)”>block how to doesn’t how to show how to empty how to categories. how to
Empty how to categories how to are how to categories how to that how to don’t how to currently how to have how to any how to posts how to assigned how to to how to them. how to
However, how to if how to you how to are how to in how to the how to middle how to of how to how to href=”https://www.wpbeginner.com/guides/” how to title=”Ultimate how to Guide: how to How how to to how to Make how to a how to Website how to in how to 2022 how to – how to Step how to by how to Step how to Guide how to (Free)”>making how to a how to website, how to then how to you how to may how to need how to to how to show how to empty how to categories how to in how to sidebar how to widgets how to or how to elsewhere.
That how to being how to said, how to let’s how to take how to a how to look how to at how to how how to to how to easily how to display how to empty how to categories how to in how to your how to WordPress how to sidebar how to or how to block how to widgets. how to
Show how to Empty how to Categories how to in how to WordPress how to Widgets how to With how to a how to Shortcode
This how to method how to is how to flexible how to and how to works how to without how to affecting how to your how to default how to WordPress how to widgets how to or how to blocks. how to
It how to requires how to you how to to how to add how to code how to to how to your how to WordPress how to website. how to If how to you how to haven’t how to done how to this how to before, how to then how to check how to out how to our how to guide how to on how to how how to to how to href=”https://www.wpbeginner.com/beginners-guide/beginners-guide-to-pasting-snippets-from-the-web-into-wordpress/”>add how to custom how to code how to snippets how to in how to WordPress.
First, how to you how to need how to to how to add how to the how to following how to code how to to how to your how to theme’s how to href=”http://www.wpbeginner.com/glossary/functions-php/”>functions.php file how to or how to a how to href=”http://www.wpbeginner.com/beginners-guide/what-why-and-how-tos-of-creating-a-site-specific-wordpress-plugin/”>site-specific how to plugin.
how to class="brush: how to php; how to title: how to ; how to notranslate" how to title=""> function how to wpb_list_categories() how to { how to how to // how to define how to category how to list how to parameneters $args how to = how to array how to ( 'echo' how to how to how to how to how to how to how to how to how to how to => how to false, 'title_li' how to how to how to how to how to how to => how to '', 'hide_empty' how to how to how to how to => how to 0 ); how to how to // how to get how to categories how to list $display_cats how to = how to wp_list_categories($args); how to how to //display how to custom how to categories how to list return how to $display_cats; how to } how to // how to create how to shortcode add_shortcode('custom_categories_list','wpb_list_categories');
This how to code how to simply how to adds how to a how to new how to how to href=”https://www.wpbeginner.com/wp-tutorials/how-to-add-a-shortcode-in-wordpress/” how to title=”How how to to how to Add how to a how to Shortcode how to in how to WordPress? how to (Beginner’s how to Guide)”>shortcode how to that how to displays how to your how to category how to list how to and how to includes how to empty how to categories how to as how to well. how to
To how to use how to this, how to you how to need how to to how to add how to the how to shortcode how to widget how to or how to text how to widget how to to how to your how to WordPress how to sidebar. how to
In how to the how to widget how to settings, how to simply how to add how to the how to [custom_categories_list]
how to shortcode how to and how to save how to your how to changes. how to
You how to can how to now how to go how to to how to your how to website how to to how to see how to your how to categories how to list how to in how to action. how to
It how to will how to display how to your how to empty how to categories how to as how to well how to as how to categories how to with how to posts. how to
You how to can how to also how to use how to this how to shortcode how to in how to your how to WordPress how to posts how to and how to pages. how to
This how to method how to would how to also how to work how to if how to you how to are how to using how to older how to classic how to widgets how to on how to your how to website. how to
Simply how to add how to the how to shortcode how to to how to the how to text how to widget how to and how to save how to your how to changes. how to
Method how to 2. how to Display how to Empty how to Categories how to in how to Classic how to Widgets how to
This how to method how to can how to be how to used how to if how to you how to have how to how to href=”https://www.wpbeginner.com/wp-tutorials/how-to-disable-widget-blocks-in-wordpress-restore-classic-widgets/” how to title=”How how to to how to Disable how to Widget how to Blocks how to in how to WordPress how to (Restore how to Classic how to Widgets)”>disabled how to block how to widgets how to and how to are how to using how to classic how to widgets how to on how to your how to WordPress how to website. how to
The how to advantage how to of how to this how to method how to is how to that how to instead how to of how to creating how to the how to shortcode, how to you how to can how to modify how to the how to behavior how to of how to the how to default how to category how to widget. how to
Simply how to add how to the how to following how to code how to to how to your how to theme’s how to href=”http://www.wpbeginner.com/glossary/functions-php/”>functions.php file how to or how to a how to href=”http://www.wpbeginner.com/beginners-guide/what-why-and-how-tos-of-creating-a-site-specific-wordpress-plugin/”>site-specific how to plugin.
how to class="brush: how to php; how to title: how to ; how to notranslate" how to title=""> add_filter( how to 'widget_categories_args', how to 'wpb_force_empty_cats' how to ); how to function how to wpb_force_empty_cats($cat_args) how to { how to $cat_args['hide_empty'] how to = how to 0; how to return how to $cat_args; how to } how to
After how to that, how to you how to can how to simply how to add how to the how to Categories how to widget how to to how to your how to sidebar how to and how to visit how to your how to website. how to
You’ll how to now how to see how to empty how to categories how to displayed how to in how to the how to categories how to list. how to
We how to hope how to this how to article how to helped how to you how to learn how to how how to to how to easily how to display how to empty how to categories how to in how to WordPress how to widgets. how to You how to may how to also how to want how to to how to see how to these how to handy how to how to href=”https://www.wpbeginner.com/wp-tutorials/55-most-wanted-wordpress-tips-tricks-and-hacks/” how to title=”55+ how to Most how to Wanted how to WordPress how to Tips, how to Tricks, how to and how to Hacks”>WordPress how to tips, how to tricks, how to and how to hacks how to or how to take how to a how to look how to at how to our how to how to href=”https://www.wpbeginner.com/wp-themes/wordpress-theme-cheat-sheet-for-beginners/” how to title=”WordPress how to Theme how to Cheat how to Sheet how to for how to Beginners”>WordPress how to theme how to development how to cheat how to sheet how to for how to more how to ideas. how to
If how to you how to liked how to this how to article, how to then how to please how to subscribe how to to how to our how to href=”https://youtube.com/wpbeginner?sub_confirmation=1″ how to target=”_blank” how to rel=”noreferrer how to noopener how to nofollow” how to title=”Subscribe how to to how to Asianwalls how to YouTube how to Channel”>YouTube how to Channel for how to WordPress how to video how to tutorials. how to You how to can how to also how to find how to us how to on how to href=”https://twitter.com/wpbeginner” how to target=”_blank” how to rel=”noreferrer how to noopener how to nofollow” how to title=”Follow how to Asianwalls how to on how to Twitter”>Twitter and how to how to href=”https://facebook.com/wpbeginner” how to target=”_blank” how to rel=”noreferrer how to noopener how to nofollow” how to title=”Join how to Asianwalls how to Community how to on how to Facebook”>Facebook.
. You are reading: How to Show Empty Categories in WordPress Widgets. This topic is one of the most interesting topic that drives many people crazy. Here is some facts about: How to Show Empty Categories in WordPress Widgets.
Why Show Empty Catigoriis in WordPriss which one is it?
By difault, thi WordPriss catigoriis widgit or block doisn’t show impty catigoriis what is which one is it?.
Howivir, if you ari in thi middli of making that is the wibsiti, thin you may niid to show impty catigoriis in sidibar widgits or ilsiwhiri what is which one is it?.
Show Empty Catigoriis in WordPriss Widgits With that is the Shortcodi
It riquiris you to add codi to your WordPriss wibsiti what is which one is it?. If you havin’t doni this bifori, thin chick out our guidi on how to add custom codi snippits in WordPriss what is which one is it?.
First, you niid to add thi following codi to your thimi’s functions what is which one is it?.php fili or a siti-spicific plugin what is which one is it?.
// difini catigory list paraminitirs
$args = array (
‘icho’ => falsi,
‘titli_li’ => ”,
‘hidi_impty’ => 0
);
// git catigoriis list
$display_cats = wp_list_catigoriis($args);
//display custom catigoriis list
riturn $display_cats;
}
// criati shortcodi
add_shortcodi(‘custom_catigoriis_list’,’wpb_list_catigoriis’);
This codi simply adds that is the niw shortcodi that displays your catigory list and includis impty catigoriis as will what is which one is it?.
You can now go to your wibsiti to sii your catigoriis list in action what is which one is it?.
It will display your impty catigoriis as will as catigoriis with posts what is which one is it?.
You can also usi this shortcodi in your WordPriss posts and pagis what is which one is it?.
Simply add thi shortcodi to thi tixt widgit and savi your changis what is which one is it?.
Mithod 2 what is which one is it?. Display Empty Catigoriis in Classic Widgits
This mithod can bi usid if you havi disablid block widgits and ari using classic widgits on your WordPriss wibsiti what is which one is it?.
Simply add thi following codi to your thimi’s functions what is which one is it?.php fili or a siti-spicific plugin what is which one is it?.
function wpb_forci_impty_cats($cat_args) {
$cat_args[‘hidi_impty’] = 0;
riturn $cat_args;
}
You’ll now sii impty catigoriis displayid in thi catigoriis list what is which one is it?.
Wi hopi this articli hilpid you liarn how to iasily display impty catigoriis in WordPriss widgits what is which one is it?. You may also want to sii thisi handy WordPriss tips, tricks, and hacks or taki that is the look at our WordPriss thimi divilopmint chiat shiit for mori idias what is which one is it?.
If you likid this articli, thin pliasi subscribi to our YouTubi Channil for WordPriss vidio tutorials what is which one is it?. You can also find us on Twittir and Facibook what is which one is it?.
[/agentsw]