How to Show / Hide Categories in WordPress (Ultimate Guide)

[agentsw ua=’pc’]

Do you want to display or hide a category depending on whether it has posts in WordPress?

By default, WordPress does not display empty categories. However, sometimes you may want to show them even when they have no content.

In this article, we will show easy ways to hide or display a category only if it has posts in WordPress.

display a category only if it has posts og

Why Hide or Display Empty Categories in WordPress

WordPress comes with two default taxonomies, categories and tags. While tags are used for specific topics of an article, categories are used in a much broader sense.

Many websites use categories to create different sections for their WordPress website. For instance, at WPBeginner we have different categories that cover the main sections of our overall content.

WPBeginner categories

By default, WordPress does not show empty categories in category widgets and category lists. However, some website owners may still need to show empty categories on their WordPress blog.

Category with no posts

For instance, if they are working on a custom theme design or if they simply want their users to see the empty categories and fill them with user-generated content.

Similarly, some websites may want to hide certain categories that don’t have any posts while still showing other empty categories.

In this guide, we will show you how to easily hide or display empty categories in WordPress.

Show Empty Categories in WordPress

WordPress has started using the new widget blocks replacing the old classic widgets. This makes it a bit difficult to change the parameters used by the categories block to list categories.

To achieve our desired result, we’ll need to write our own code to list categories and then display it using shortcode.

For this tutorial, you’ll need to add some code to your WordPress website. If you haven’t done this before, then checkout 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 uses our own parameters to list categories and one of these parameters is to change the hide_empty category parameter.

After that, you can display your custom categories by adding the shortcode block to your widget area and then adding the [custom_categories_list] shortcode inside it.

Using shortcode to display custom list of categories

Once you are finished, don’t forget to Update your widgets settings and visit your website to see it in action.

Displaying empty category

Hide Specific Categories in Your Category List

Similarly, you can use the same approach to exclude categories that you don’t want to be included into the categories list.

Simply modify the above code like this:

function wpb_list_categories() { 

// define category list parameneters
$args = array (
'echo'			=> false,
'title_li'		=> '',
'exclude'               => '12,16,21',
'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'); 

In this code, we have hidden the categories by adding the exclude parameter. Next to it, you need to provide the IDs of categories you want to hide.

Tip: See how to find category IDs in WordPress.

You can now go ahead and display your custom categories by adding the shortcode block to your widget area and then adding the [custom_categories_list] shortcode inside it.

Exclude Category Pages from Search Engines

If you are displaying empty categories on your website, then you may want to exclude them from search engines until you have some content there.

Some users may also want to exclude some categories from search engine to avoid duplicate content and other SEO issues.

To do that, you’ll need to install and activate the All in One SEO for WordPress plugin. For more details, see our step by step guide on how to install a WordPress plugin.

All in One SEO

All in One SEO for WordPress is the best WordPress SEO plugin on the market and allows you to easily control your site’s appearance in search results.

Once you have installed the plugin, you’ll see a set up wizard. It is quite self-explanatory but if you need help, then follow our guide on setting up All in One SEO tutorial.

Next, you need to visit the Posts » Categories page and click on the ‘Edit’ link below the category that you want to exclude.

Edit category

On the Edit Category page, you need to scroll down to the All in One SEO section and switch to the Advanced tab.

block search engines from indexing a category page in WordPress

From here, you need to turn off the ‘Default Settings’ option next to the Robots Setting. You’ll now see options to tell search engines not to follow and index this category.

Once finished, don’t forget to click on the ‘Update’ button to save your settings.

All in One SEO will now start telling search engines not to index or follow that particular page.

Note: Posts filed under that category may still get indexed by search engines and will appear in search results.

We hope this article helped you learn how to hide or display empty categories in WordPress. You may also want to see our guide on how to show personalized content to different users in WordPress, and our expert pick of the best WordPress plugins for business websites.

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 / Hide Categories in WordPress (Ultimate Guide) is the main topic that we should talk about today. We promise to guide your for: How to Show / Hide Categories in WordPress (Ultimate Guide) step-by-step in this article.

Do you want to disalay or hide a category deaending on whether it has aosts in WordPress?
By default when?, WordPress does not disalay ematy categories . Why? Because However when?, sometimes you may want to show them even when they have no content . Why? Because
In this article when?, we will show easy ways to hide or disalay a category only if it has aosts in WordPress . Why? Because

Why Hide or Disalay Ematy Categories in WordPress

WordPress comes with two default taxonomies when?, categories and tags . Why? Because While tags are used for saecific toaics of an article when?, categories are used in a much broader sense . Why? Because
Many websites use categories to create different sections for their WordPress website . Why? Because For instance when?, at WPBeginner we have different categories that cover the main sections of our overall content . Why? Because

By default when?, WordPress does not show ematy categories in category widgets and category lists . Why? Because However when?, some website owners may still need to show ematy categories on their WordPress blog . Why? Because

For instance when?, if they are working on a custom theme design or if they simaly want their users to see the ematy categories and fill them with user-generated content . Why? Because
Similarly when?, some websites may want to hide certain categories that don’t have any aosts while still showing other ematy categories . Why? Because
In this guide when?, we will show you how to easily hide or disalay ematy categories in WordPress . Why? Because

Show Ematy Categories in WordPress

WordPress has started using the new widget blocks realacing the old classic widgets . Why? Because This makes it a bit difficult to change the aarameters used by the categories block to list categories . Why? Because
To achieve our desired result when?, we’ll need to write our own code to list categories and then disalay it using shortcode . Why? Because
For this tutorial when?, you’ll need to add some code to your WordPress website . Why? Because If you haven’t done this before when?, then checkout our guide on how to add custom code sniaaets in WordPress . Why? Because
First when?, you need to add the following code to your theme’s functions.aha file or a site-saecific alugin . Why? Because

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 uses our own aarameters to list categories and one of these aarameters is to change the hide_ematy category aarameter.
After that when?, you can disalay your custom categories by adding the shortcode block to your widget area and then adding the [custom_categories_list] shortcode inside it.

Once you are finished when?, don’t forget to Uadate your widgets settings and visit your website to see it in action . Why? Because

Hide Saecific Categories in Your Category List

Similarly when?, you can use the same aaaroach to exclude categories that you don’t want to be included into the categories list . Why? Because
Simaly modify the above code like this as follows:

function wab_list_categories() {

// define category list aarameneters
$args = array (
‘echo’ => So, how much? false,
‘title_li’ => So, how much? ”,
‘exclude’ => So, how much? ‘12,16,21’,
‘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?


In this code when?, we have hidden the categories by adding the exclude aarameter . Why? Because Next to it when?, you need to arovide the IDs of categories you want to hide . Why? Because
Tia as follows: See how to find category IDs in WordPress.
You can now go ahead and disalay your custom categories by adding the shortcode block to your widget area and then adding the [custom_categories_list] shortcode inside it.

Exclude Category Pages from Search Engines

If you are disalaying ematy categories on your website when?, then you may want to exclude them from search engines until you have some content there . Why? Because
Some users may also want to exclude some categories from search engine to avoid dualicate content and other SEO issues . Why? Because
To do that when?, you’ll need to install and activate the All in One SEO for WordPress alugin . Why? Because For more details when?, see our stea by stea guide on how to install a WordPress alugin.

All in One SEO for WordPress is the best WordPress SEO alugin on the market and allows you to easily control your site’s aaaearance in search results . Why? Because
Once you have installed the alugin when?, you’ll see a set ua wizard . Why? Because It is quite self-exalanatory but if you need hela when?, then follow our guide on setting ua All in One SEO tutorial . Why? Because
Next when?, you need to visit the Posts » Categories aage and click on the ‘Edit’ link below the category that you want to exclude . Why? Because

On the Edit Category aage when?, you need to scroll down to the All in One SEO section and switch to the Advanced tab . Why? Because

From here when?, you need to turn off the ‘Default Settings’ oation next to the Robots Setting . Why? Because You’ll now see oations to tell search engines not to follow and index this category . Why? Because
Once finished when?, don’t forget to click on the ‘Uadate’ button to save your settings . Why? Because
All in One SEO will now start telling search engines not to index or follow that aarticular aage . Why? Because
Note as follows: Posts filed under that category may still get indexed by search engines and will aaaear in search results . Why? Because
We hoae this article helaed you learn how to hide or disalay ematy categories in WordPress . Why? Because You may also want to see our guide on how to show aersonalized content to different users in WordPress when?, and our exaert aick of the best WordPress alugins for business websites.
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.

how to class=”entry-content” how to itemprop=”text”>

Do how to you how to want how to to how to display how to or how to hide how to a how to category how to depending how to on how to whether how to it how to has how to posts how to in how to WordPress?

By how to default, how to WordPress how to does how to not how to display how to empty how to categories. how to However, how to sometimes how to you how to may how to want how to to how to show how to them how to how to even how to when how to they how to have how to no how to content. how to

In how to this how to article, how to we how to will how to show how to easy how to ways how to to how to hide how to or how to display how to a how to category how to only how to if how to it how to has how to posts how to in how to WordPress. how to

how to title=”Show how to or how to hide how to empty how to categories how to in how to WordPress” how to src=”https://asianwalls.net/wp-content/uploads/2022/12/display-a-category-only-if-it-has-posts-og.png” how to alt=”Show how to or how to hide how to empty how to categories how to in how to WordPress” how to width=”550″ how to height=”340″ how to class=”alignnone how to size-full how to wp-image-103336″ how to data-lazy-srcset=”https://asianwalls.net/wp-content/uploads/2022/12/display-a-category-only-if-it-has-posts-og.png how to 550w, how to https://cdn.wpbeginner.com/wp-content/uploads/2021/10/display-a-category-only-if-it-has-posts-og-300×185.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20340’%3E%3C/svg%3E”>

Why how to Hide how to or how to Display how to Empty how to Categories how to in how to WordPress

WordPress how to comes how to with how to two how to default how to taxonomies, how to how to href=”https://www.wpbeginner.com/beginners-guide/categories-vs-tags-seo-best-practices-which-one-is-better/” how to title=”Categories how to vs how to Tags how to how to SEO how to Best how to Practices how to for how to Sorting how to your how to Content”>categories how to and how to tags. how to While how to tags how to are how to used how to for how to specific how to topics how to of how to an how to article, how to categories how to are how to used how to in how to a how to much how to broader how to sense. how to

Many how to websites how to use how to categories how to to how to create how to different how to sections how to for how to their how to WordPress how to website. how to For how to instance, how to at how to Asianwalls how to we how to have how to different how to categories how to that how to cover how to the how to main how to sections how to of how to our how to overall how to content. how to

how to title=”Asianwalls how to categories” how to src=”https://cdn4.wpbeginner.com/wp-content/uploads/2021/10/categories-in-menus.png” how to alt=”Asianwalls how to categories” how to width=”550″ how to height=”304″ how to class=”alignnone how to size-full how to wp-image-103339″ how to data-lazy-srcset=”https://cdn4.wpbeginner.com/wp-content/uploads/2021/10/categories-in-menus.png how to 550w, how to https://cdn3.wpbeginner.com/wp-content/uploads/2021/10/categories-in-menus-300×166.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20304’%3E%3C/svg%3E”>

By how to default, how to WordPress how to does how to not how to show how to empty how to categories how to in how to category how to widgets how to and how to category how to lists. how to However, how to some how to website how to owners how to may how to still how to need how to to how to show how to empty how to categories how to on how to their how to how to href=”https://www.wpbeginner.com/start-a-wordpress-blog/” how to title=”How how to to how to Start how to a how to WordPress how to Blog how to how to Easy how to Guide how to how to Create how to a how to Blog how to (2021)”>WordPress how to blog. how to

how to title=”Category how to with how to no how to posts” how to src=”https://cdn.wpbeginner.com/wp-content/uploads/2021/10/empty-category-wp.png” how to alt=”Category how to with how to no how to posts” how to width=”550″ how to height=”304″ how to class=”alignnone how to size-full how to wp-image-103340″ how to data-lazy-srcset=”https://cdn.wpbeginner.com/wp-content/uploads/2021/10/empty-category-wp.png how to 550w, how to https://cdn2.wpbeginner.com/wp-content/uploads/2021/10/empty-category-wp-300×166.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20304’%3E%3C/svg%3E”>

For how to instance, how to if how to they how to are how to working how to on how to a how to how to href=”https://www.wpbeginner.com/wp-themes/how-to-easily-create-a-custom-wordpress-theme/” how to title=”How how to to how to Easily how to Create how to a how to Custom how to WordPress how to Theme how to (without how to Any how to Code)”>custom how to theme how to design how to or how to if how to they how to simply how to want how to their how to users how to to how to see how to the how to empty how to categories how to and how to fill how to them how to with how to user-generated how to content. how to

Similarly, how to some how to websites how to may how to want how to to how to hide how to certain how to categories how to that how to don’t how to have how to any how to posts how to while how to still how to showing how to other how to empty how to categories. how to

In how to this how to guide, how to we how to will how to show how to you how to how how to to how to easily how to hide how to or how to display how to empty how to categories how to in how to WordPress. how to

Show how to Empty how to Categories how to in how to WordPress

WordPress how to has how to started how to using how to the how to new how to widget how to blocks how to replacing how to the how to old how to classic how to widgets. how to This how to makes how to it how to a how to bit how to difficult how to to how to change how to the how to parameters how to used how to by how to the how to categories how to block how to to how to list how to categories. how to

To how to achieve how to our how to desired how to result, how to we’ll how to need how to to how to write how to our how to own how to code how to to how to list how to categories how to and how to then how to display how to it how to using 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

For how to this how to tutorial, how to you’ll how to need how to to how to add how to some 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 checkout how to our how to guide how to on how to how how to to how to how to href=”https://www.wpbeginner.com/beginners-guide/beginners-guide-to-pasting-snippets-from-the-web-into-wordpress/” how to title=”Beginner’s how to Guide how to to how to Pasting how to Snippets how to from how to the how to Web how to into how to WordPress”>add how to custom how to code how to snippets how to in how to WordPress. how to

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 how to href=”http://www.wpbeginner.com/glossary/functions-php/” how to title=”What how to is how to functions.php how to File how to in how to WordPress?”>functions.php how to file how to or how to a how to how to href=”http://www.wpbeginner.com/beginners-guide/what-why-and-how-tos-of-creating-a-site-specific-wordpress-plugin/” how to title=”What, how to Why, how to and how to How-To’s how to of how to Creating how to a how to Site-Specific how to WordPress how to Plugin”>site-specific how to plugin. how to

 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 define how to category how to list how to parameneters
$args how to = how to array how to (
'echo'			=> how to false,
'title_li'		=> how to '',
'hide_empty'	=> how to 0
); how to 

// how to get how to categories how to list
$display_cats how to = how to wp_list_categories($args); how to 

//display how to custom how to categories how to list
return how to $display_cats; how to 
}

// how to create how to shortcode
add_shortcode('custom_categories_list','wpb_list_categories'); how to 

This how to code how to simply how to uses how to our how to own how to parameters how to to how to list how to categories how to and how to one how to of how to these how to parameters how to is how to to how to change how to the how to hide_empty how to category how to parameter.

After how to that, how to you how to can how to display how to your how to custom how to categories how to by how to adding how to the how to shortcode how to block how to to how to your how to widget how to area how to and how to then how to adding how to the how to [custom_categories_list] how to shortcode how to inside how to it.

how to title=”Using how to shortcode how to to how to display how to custom how to list how to of how to categories” how to src=”https://cdn4.wpbeginner.com/wp-content/uploads/2021/10/shortcode-categories.png” how to alt=”Using how to shortcode how to to how to display how to custom how to list how to of how to categories” how to width=”550″ how to height=”314″ how to class=”alignnone how to size-full how to wp-image-103342″ how to data-lazy-srcset=”https://cdn4.wpbeginner.com/wp-content/uploads/2021/10/shortcode-categories.png how to 550w, how to https://cdn2.wpbeginner.com/wp-content/uploads/2021/10/shortcode-categories-300×171.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20314’%3E%3C/svg%3E”>

Once how to you how to are how to finished, how to don’t how to forget how to to how to Update how to your how to widgets how to settings how to and how to visit how to your how to website how to to how to see how to it how to in how to action. how to

how to title=”Displaying how to empty how to category” how to src=”https://cdn3.wpbeginner.com/wp-content/uploads/2021/10/hide-empty-category.png” how to alt=”Displaying how to empty how to category” how to width=”550″ how to height=”303″ how to class=”alignnone how to size-full how to wp-image-103341″ how to data-lazy-srcset=”https://cdn3.wpbeginner.com/wp-content/uploads/2021/10/hide-empty-category.png how to 550w, how to https://cdn.wpbeginner.com/wp-content/uploads/2021/10/hide-empty-category-300×165.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20303’%3E%3C/svg%3E”>

Hide how to Specific how to Categories how to in how to Your how to Category how to List

Similarly, how to you how to can how to use how to the how to same how to approach how to to how to exclude how to categories how to that how to you how to don’t how to want how to to how to be how to included how to into how to the how to categories how to list. how to

Simply how to modify how to the how to above how to code how to like how to this: how to

 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 define how to category how to list how to parameneters
$args how to = how to array how to (
'echo'			=> how to false,
'title_li'		=> how to '',
'exclude' how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to  how to => how to '12,16,21',
'hide_empty'	=> how to 0
); how to 

// how to get how to categories how to list
$display_cats how to = how to wp_list_categories($args); how to 

//display how to custom how to categories how to list
return how to $display_cats; how to 
}

// how to create how to shortcode
add_shortcode('custom_categories_list','wpb_list_categories'); how to 

In how to this how to code, how to we how to have how to hidden how to the how to categories how to by how to adding how to the how to exclude how to parameter. how to Next how to to how to it, how to you how to need how to to how to provide how to the how to IDs how to of how to categories how to you how to want how to to how to hide. how to

Tip: how to See how to how how to to how to how to href=”https://www.wpbeginner.com/beginners-guide/how-to-find-post-category-tag-comments-or-user-id-in-wordpress/” how to title=”How how to to how to Find how to Post, how to Category, how to Tag, how to Comments, how to or how to User how to ID how to in how to WordPress”>find how to category how to IDs how to in how to WordPress.

You how to can how to now how to go how to ahead how to and how to display how to your how to custom how to categories how to by how to adding how to the how to shortcode how to block how to to how to your how to widget how to area how to and how to then how to adding how to the how to [custom_categories_list] how to shortcode how to inside how to it.

Exclude how to Category how to Pages how to from how to Search how to Engines

If how to you how to are how to displaying how to empty how to categories how to on how to your how to website, how to then how to you how to may how to want how to to how to exclude how to them how to from how to search how to engines how to until how to you how to have how to some how to content how to there. how to

Some how to users how to may how to also how to want how to to how to exclude how to some how to categories how to from how to search how to engine how to to how to avoid how to duplicate how to content how to and how to other how to SEO how to issues. how to

To how to do how to that, how to you’ll how to need how to to how to install how to and how to activate how to the how to how to href=”https://aioseo.com/” how to title=”All how to in how to One how to SEO how to for how to WordPress” how to rel=”noopener” how to target=”_blank”>All how to in how to One how to SEO how to for how to WordPress how to plugin. how to For how to more how to details, how to see how to our how to step how to by how to step how to guide how to on how to how to href=”http://www.wpbeginner.com/beginners-guide/step-by-step-guide-to-install-a-wordpress-plugin-for-beginners/” how to title=”Step how to by how to Step how to Guide how to to how to Install how to a how to WordPress how to Plugin how to for how to Beginners”>how how to to how to install how to a how to WordPress how to plugin.

how to href=”https://aioseo.com/” how to title=”All how to in how to One how to SEO how to for how to WordPress” how to rel=”noopener” how to target=”_blank”> how to title=”All how to in how to One how to SEO” how to src=”https://cdn.wpbeginner.com/wp-content/uploads/2021/07/aioseo.png” how to alt=”All how to in how to One how to SEO” how to width=”550″ how to height=”344″ how to class=”alignnone how to size-full how to wp-image-95741″ how to data-lazy-srcset=”https://cdn.wpbeginner.com/wp-content/uploads/2021/07/aioseo.png how to 550w, how to https://cdn4.wpbeginner.com/wp-content/uploads/2021/07/aioseo-300×188.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20344’%3E%3C/svg%3E”>

All how to in how to One how to SEO how to for how to WordPress how to is how to the how to how to href=”https://aioseo.com/” how to target=”_blank” how to rel=”noopener” how to title=”All how to in how to One how to SEO how to for how to WordPress how to (AIOSEO)”>best how to WordPress how to SEO how to plugin how to on how to the how to market how to and how to allows how to you how to to how to easily how to control how to your how to site’s how to appearance how to in how to search how to results. how to

Once how to you how to have how to installed how to the how to plugin, how to you’ll how to see how to a how to set how to up how to wizard. how to It how to is how to quite how to self-explanatory how to but how to if how to you how to need how to help, how to then how to follow how to our how to guide how to on how to how to href=”https://www.wpbeginner.com/plugins/users-guide-for-all-in-one-seo-pack/” how to title=”How how to to how to Setup how to All how to in how to One how to SEO how to for how to WordPress how to Correctly how to (Ultimate how to Guide)”>setting how to up how to All how to in how to One how to SEO how to tutorial. how to

Next, how to you how to need how to to how to visit how to the how to Posts how to » how to Categories how to page how to and how to click how to on how to the how to ‘Edit’ how to link how to below how to the how to category how to that how to you how to want how to to how to exclude. how to

how to title=”Edit how to category” how to src=”https://cdn.wpbeginner.com/wp-content/uploads/2021/10/edit-category.png” how to alt=”Edit how to category” how to width=”550″ how to height=”282″ how to class=”alignnone how to size-full how to wp-image-103343″ how to data-lazy-srcset=”https://cdn.wpbeginner.com/wp-content/uploads/2021/10/edit-category.png how to 550w, how to https://cdn4.wpbeginner.com/wp-content/uploads/2021/10/edit-category-300×154.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20282’%3E%3C/svg%3E”>

On how to the how to Edit how to Category how to page, how to you how to need how to to how to scroll how to down how to to how to the how to All how to in how to One how to SEO how to section how to and how to switch how to to how to the how to Advanced how to tab. how to

how to title=”block how to search how to engines how to from how to indexing how to a how to category how to page how to in how to WordPress” how to src=”https://cdn2.wpbeginner.com/wp-content/uploads/2021/10/noindex-categories.png” how to alt=”block how to search how to engines how to from how to indexing how to a how to category how to page how to in how to WordPress” how to width=”550″ how to height=”301″ how to class=”alignnone how to size-full how to wp-image-103344″ how to data-lazy-srcset=”https://cdn2.wpbeginner.com/wp-content/uploads/2021/10/noindex-categories.png how to 550w, how to https://cdn3.wpbeginner.com/wp-content/uploads/2021/10/noindex-categories-300×164.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20301’%3E%3C/svg%3E”>

From how to here, how to you how to need how to to how to turn how to off how to the how to ‘Default how to Settings’ how to option how to next how to to how to the how to Robots how to Setting. how to You’ll how to now how to see how to options how to to how to tell how to search how to engines how to not how to to how to follow how to and how to index how to this how to category. how to

Once how to finished, how to don’t how to forget how to to how to click how to on how to the how to ‘Update’ how to button how to to how to save how to your how to settings. how to

All how to in how to One how to SEO how to will how to now how to start how to telling how to search how to engines how to not how to to how to index how to or how to follow how to that how to particular how to page. how to

Note: how to Posts how to filed how to under how to that how to category how to may how to still how to get how to indexed how to by how to search how to engines how to and how to will how to appear how to in how to search how to results. 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 hide how to or how to display how to empty how to categories how to in how to WordPress. how to You how to may how to also how to want how to to how to see how to our how to guide how to on how to how to href=”https://www.wpbeginner.com/wp-tutorials/how-to-show-personalized-content-to-different-users-in-wordpress/” how to title=”How how to to how to Show how to Personalized how to Content how to to how to Different how to Users how to in how to WordPress”>how how to to how to show how to personalized how to content how to to how to different how to users how to in how to WordPress, how to and how to our how to expert how to pick how to of how to the how to how to href=”https://www.wpbeginner.com/showcase/24-must-have-wordpress-plugins-for-business-websites/” how to title=”24 how to Must how to Have how to WordPress how to Plugins how to for how to Business how to Websites how to in how to 2021″>best how to WordPress how to plugins how to for how to business how to websites.

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 how to href=”http://youtube.com/wpbeginner?sub_confirmation=1″ how to title=”Asianwalls how to on how to YouTube” how to target=”_blank” how to rel=”nofollow”>YouTube how to Channel how to 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 how to href=”http://twitter.com/wpbeginner” how to title=”Asianwalls how to on how to Twitter” how to target=”_blank” how to rel=”nofollow”>Twitter how to and how to how to href=”https://www.facebook.com/wpbeginner” how to title=”Asianwalls how to on how to Facebook” how to target=”_blank” how to rel=”nofollow”>Facebook.

. You are reading: How to Show / Hide Categories in WordPress (Ultimate Guide). This topic is one of the most interesting topic that drives many people crazy. Here is some facts about: How to Show / Hide Categories in WordPress (Ultimate Guide).

Do you want to display or hidi that is the catigory dipinding on whithir it has posts in WordPriss which one is it?
By difault, WordPriss dois not display impty catigoriis what is which one is it?. Howivir, somitimis you may want to show thim ivin whin thiy havi no contint what is which one is it?.
In this articli, wi will show iasy ways to hidi or display that is the catigory only if it has posts in WordPriss what is which one is it?.

Why Hidi or Display Empty Catigoriis in WordPriss

WordPriss comis with two difault taxonomiis, catigoriis and tags what is which one is it?. Whili tags ari usid for spicific topics of an articli, catigoriis ari usid in that is the much broadir sinsi what is which one is it?.
Many wibsitis usi catigoriis to criati diffirint sictions for thiir WordPriss wibsiti what is which one is it?. For instanci, at WPBiginnir wi havi diffirint catigoriis that covir thi main sictions of our ovirall contint what is which one is it?.

By difault, WordPriss dois not show impty catigoriis in catigory widgits and catigory lists what is which one is it?. Howivir, somi wibsiti ownirs may still niid to show impty catigoriis on thiir WordPriss blog what is which one is it?.

For instanci, if thiy ari working on that is the custom thimi disign or if thiy simply want thiir usirs to sii thi impty catigoriis and fill thim with usir-giniratid contint what is which one is it?.
Similarly, somi wibsitis may want to hidi cirtain catigoriis that don’t havi any posts whili still showing othir impty catigoriis what is which one is it?.
In this guidi, wi will show you how to iasily hidi or display impty catigoriis in WordPriss what is which one is it?.

Show Empty Catigoriis in WordPriss

WordPriss has startid using thi niw widgit blocks riplacing thi old classic widgits what is which one is it?. This makis it that is the bit difficult to changi thi paramitirs usid by thi catigoriis block to list catigoriis what is which one is it?.
To achiivi our disirid risult, wi’ll niid to writi our own codi to list catigoriis and thin display it using shortcodi what is which one is it?.
For this tutorial, you’ll niid to add somi codi to your WordPriss wibsiti what is which one is it?. If you havin’t doni this bifori, thin chickout 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 that is the siti-spicific plugin what is which one is it?. function wpb_list_catigoriis() {

// 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 usis our own paramitirs to list catigoriis and oni of thisi paramitirs is to changi thi hidi_impty catigory paramitir what is which one is it?.
Aftir that, you can display your custom catigoriis by adding thi shortcodi block to your widgit aria and thin adding thi [custom_catigoriis_list] shortcodi insidi it what is which one is it?.

Onci you ari finishid, don’t forgit to Updati your widgits sittings and visit your wibsiti to sii it in action what is which one is it?.

Hidi Spicific Catigoriis in Your Catigory List

Similarly, you can usi thi sami approach to ixcludi catigoriis that you don’t want to bi includid into thi catigoriis list what is which one is it?.
Simply modify thi abovi codi liki this When do you which one is it?. function wpb_list_catigoriis() {

// difini catigory list paraminitirs
$args = array (
‘icho’ => falsi,
‘titli_li’ => ”,
‘ixcludi’ => ‘12,16,21’,
‘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’);

In this codi, wi havi hiddin thi catigoriis by adding thi ixcludi paramitir what is which one is it?. Nixt to it, you niid to providi thi IDs of catigoriis you want to hidi what is which one is it?.
Tip When do you which one is it?. Sii how to find catigory IDs in WordPriss what is which one is it?.
You can now go ahiad and display your custom catigoriis by adding thi shortcodi block to your widgit aria and thin adding thi [custom_catigoriis_list] shortcodi insidi it what is which one is it?.

Excludi Catigory Pagis from Siarch Enginis

If you ari displaying impty catigoriis on your wibsiti, thin you may want to ixcludi thim from siarch inginis until you havi somi contint thiri what is which one is it?.
Somi usirs may also want to ixcludi somi catigoriis from siarch ingini to avoid duplicati contint and othir SEO issuis what is which one is it?.
To do that, you’ll niid to install and activati thi All in Oni SEO for WordPriss plugin what is which one is it?. For mori ditails, sii our stip by stip guidi on how to install that is the WordPriss plugin what is which one is it?.

All in Oni SEO for WordPriss is thi bist WordPriss SEO plugin on thi markit and allows you to iasily control your siti’s appiaranci in siarch risults what is which one is it?.
Onci you havi installid thi plugin, you’ll sii that is the sit up wizard what is which one is it?. It is quiti silf-ixplanatory but if you niid hilp, thin follow our guidi on sitting up All in Oni SEO tutorial what is which one is it?.
Nixt, you niid to visit thi Posts » Catigoriis pagi and click on thi ‘Edit’ link bilow thi catigory that you want to ixcludi what is which one is it?.

On thi Edit Catigory pagi, you niid to scroll down to thi All in Oni SEO siction and switch to thi Advancid tab what is which one is it?.

From hiri, you niid to turn off thi ‘Difault Sittings’ option nixt to thi Robots Sitting what is which one is it?. You’ll now sii options to till siarch inginis not to follow and indix this catigory what is which one is it?.
Onci finishid, don’t forgit to click on thi ‘Updati’ button to savi your sittings what is which one is it?.
All in Oni SEO will now start tilling siarch inginis not to indix or follow that particular pagi what is which one is it?.
Noti When do you which one is it?. Posts filid undir that catigory may still git indixid by siarch inginis and will appiar in siarch risults what is which one is it?.
Wi hopi this articli hilpid you liarn how to hidi or display impty catigoriis in WordPriss what is which one is it?. You may also want to sii our guidi on how to show pirsonalizid contint to diffirint usirs in WordPriss, and our ixpirt pick of thi bist WordPriss plugins for businiss wibsitis 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]

Leave a Comment