Hey there, WordPress user! If you‘ve ever wondered if it‘s possible to display a category only if it has posts in WordPress, you‘re in the right place. Categories are a key way to keep your WordPress site organized, but sometimes you might want more control over which ones are visible to visitors.
Maybe you want to hide categories that don‘t have any content yet, to avoid confusing users or cluttering up your navigation. Or maybe you actually want to display empty categories for a specific reason, like letting users browse topics before you‘ve published posts under them.
In this ultimate guide, we‘ll dive deep into how to show or hide categories strategically in WordPress. Whether you‘re a beginner or a more advanced user, you‘ll learn multiple methods with step-by-step instructions. Plus, get expert tips and best practices to keep your categories optimized for both SEO and user experience.
Why Hide or Display Categories Strategically?
First, let‘s look at some of the main reasons you might want to control the visibility of your WordPress categories.
Benefits of Hiding Empty Categories
WordPress automatically hides categories with no posts by default, and for most sites this makes sense. Here‘s why:
- Cleaner navigation menus: No need to show categories that won‘t have any content when clicked on
- Better user experience: Avoids leading visitors to "dead end" category pages
- Less visual clutter: Keeps your sidebar and other widget areas focused on your site‘s active content
- Perception of site size: Doesn‘t artificially inflate the apparent amount of content on your site
In most cases, hiding empty categories is the expected behavior and provides a more intuitive experience for users.
Reasons to Display Empty Categories
However, there are a few scenarios where you might actually want empty categories to be visible:
- Future planning: If you‘re developing a new site, you may want to show the categories you plan to have content for eventually, even if you haven‘t written those posts yet. This can give users an idea of your site‘s intended scope.
- Non-post content: In some cases, categories might be used to organize pages, products, or other non-post content. In this case, the categories wouldn‘t depend on having blog posts to be relevant.
- User submissions: If you have a site where users can submit posts, you may want them to be able to browse and select from the full list of allowed categories, even if some don‘t have user posts yet.
- Topic browsing: Depending on your niche, the categories may function more as general topic labels rather than a way to navigate to related posts. Showing the full "catalog" of topics could encourage users to explore more.
So while hiding empty categories is usually best, there are times when the opposite approach makes more sense. It really depends on your specific site and content strategy.
How to Show Empty Categories in WordPress
Now that we‘ve looked at the "why", let‘s get into the "how". There are two main methods for showing categories that don‘t have any posts in WordPress:
- By modifying the arguments passed to the
wp_list_categories()function in your theme files - By using a plugin to control category visibility
We‘ll walk through both methods step-by-step. Even if you‘re not comfortable with code, you‘ll be able to follow along and implement these solutions on your own site.
Showing Empty Categories with Code
The wp_list_categories() function is what WordPress uses to display category lists in the default Categories widget and other navigation elements. By modifying the arguments passed to this function, we can change the behavior to show categories even if they‘re empty.
Here‘s how:
Open up your theme‘s
functions.phpfile or a site-specific plugin where you can add custom code snippets.Paste the following code block into the file:
function custom_category_list_args( $args ) {
$args[‘hide_empty‘] = 0;
return $args;
}
add_filter( ‘widget_categories_args‘, ‘custom_category_list_args‘ );- Save the changes to the file.
Here‘s what this code does:
- It hooks into the
widget_categories_argsfilter, which modifies the arguments used for category list widgets. This filter is specifically for the Categories widget in your sidebar or other widgetized areas. - Inside the hooked function, it sets the
hide_emptyargument to0. This tellswp_list_categories()to show empty categories instead of hiding them. - Finally, it returns the modified
$argsarray back to WordPress to use when displaying the widget.
With this snippet, your Categories widget will now show the full list of categories, even if some don‘t have posts.
Note: This code will only affect Categories widgets. If you want to show empty categories in other WordPress category lists, like template tags or navigation menus, you‘ll need to use a slightly different code snippet. Here are a few other useful filters to try:
wp_list_categories_args: Affects all calls towp_list_categories()across your site, not just widgetsget_terms_args: Modifies the arguments passed to the more generalget_terms()function, which retrieves taxonomy terms
By using the appropriate filter for the location you want to modify, you can control the visibility of empty categories across your entire WordPress site.
Showing Empty Categories with Plugins
If you‘re not comfortable adding code snippets to your WordPress files, you can also show or hide empty categories with the help of plugins. Here are a few of the best options:
Reveal Empty Categories
Reveal Empty Categories is a simple, lightweight plugin that does exactly what it says. Once activated, it will display all categories in your sidebar widgets, navigation menus, and other category lists across your site – even if they don‘t have any posts.
There are no settings to configure. Just install and activate the plugin, and it will automatically start showing your empty categories. This makes it a great option if you want a quick and easy solution without any fuss.
Ultimate Category Excluder
Ultimate Category Excluder is a more comprehensive plugin that gives you fine-grained control over which categories are displayed where. In addition to showing or hiding empty categories, you can also:
- Exclude specific categories from archives, feeds, and navigation menus
- Hide categories based on post type (e.g. only show categories that have posts, pages, or custom post types)
- Display a category list using a shortcode or template tag
The plugin adds a new "Ultimate Category Excluder" settings panel where you can configure these options. For example, to show empty categories, you would check the box next to "Show Empty Categories" in the "General" tab.
One nice feature is the ability to create multiple exclusion groups, each with their own settings. This allows you to show empty categories in some places (like your sidebar) while hiding them in others (like your archives).
Category Visibility
Category Visibility is another plugin that adds more control over displaying categories. But instead of plugin-wide settings, it lets you set the visibility of each category individually.
When you edit a category in the WordPress dashboard, you‘ll see a new "Visibility" option. This lets you choose whether to show or hide that specific category, regardless of whether it has posts.
The plugin also integrates with the default Categories widget. In the widget settings, you‘ll see a checkbox to "Include Empty Categories". Enable this option, and empty categories will display in that particular widget only.
This approach is helpful if you want to show some empty categories but not others, without applying a blanket rule.
Hiding Specific Categories Altogether
In addition to hiding categories without posts, you might want to exclude certain categories from displaying at all, even if they do have published content. Some reasons to hide specific categories include:
- You want to use the category privately for backend organization, but not for public navigation
- The category is outdated or no longer relevant to your content strategy
- You‘re migrating content to a different category and want to hide the old one from users
There are a few ways to hide individual categories from your WordPress site.
Excluding Categories with Code
To hide specific categories, you can use the exclude argument in the wp_list_categories() function. This lets you specify one or more category IDs to leave out of the category list.
For example, let‘s say you wanted to exclude the category with an ID of 5. You would add this code to your theme‘s functions.php file:
function exclude_category_5($args){
$exclude = array(5);
$args[‘exclude‘] = $exclude;
return $args;
}
add_filter(‘widget_categories_args‘, ‘exclude_category_5‘);This will modify the arguments passed to the Categories widget to exclude the category with ID 5. You can add multiple category IDs to the $exclude array to hide more than one.
To find a category‘s ID, go to Posts > Categories in your WordPress dashboard. Hover over a category name and look at the URL in your browser‘s status bar. The ID number will be at the end of the URL.
You can also use the get_categories() function to retrieve an array of all categories and their IDs:
$categories = get_categories();
foreach($categories as $category) {
echo $category->name . ‘: ‘ . $category->term_id;
echo ‘<br>‘;
} This will output a list of your category names and their corresponding IDs, which you can then use in the exclude argument.
Excluding Categories with Plugins
If you prefer a plugin solution, all of the ones mentioned in the previous section also have options to exclude specific categories:
- Ultimate Category Excluder: In the settings panel, go to the "Exclude Categories" tab. Here you can select which categories to hide from various parts of your site, like navigation menus, archives, and widgets.
- Category Visibility: When editing an individual category, set the "Visibility" option to "Hide" to exclude it from displaying.
- Reveal Empty Categories: While this plugin doesn‘t have built-in exclusion settings, you can use it alongside the Ultimate Category Excluder plugin. Ultimate Category Excluder‘s settings will take priority and let you hide specific categories.
Best Practices for Organizing WordPress Categories
As we‘ve seen, being strategic about which categories you show or hide can have a big impact on your site‘s user experience and SEO. To wrap up, here are some category best practices to keep in mind as you organize your WordPress content.
Use Clear, Descriptive Category Names
When naming your categories, think about what will make sense to your visitors. Avoid clever or vague terms in favor of clear, straightforward topics. A good category name tells users exactly what kind of content they can expect to find when they click on it.
For example, a cooking blog might have categories like:
- Breakfast Recipes
- Vegetarian Dishes
- Quick & Easy Meals
- Holiday Cooking
These names are immediately understandable and help visitors find relevant content quickly.
Create a Logical Category Hierarchy
Take advantage of WordPress‘ built-in category hierarchy to group related topics together. You can create parent categories and child subcategories to organize your content in a way that‘s intuitive for users.
For instance, an e-commerce store selling clothing might have a top-level "Apparel" category with subcategories like:
- Apparel
- Tops
- T-Shirts
- Sweaters
- Blouses
- Bottoms
- Pants
- Shorts
- Skirts
- Outerwear
- Coats
- Jackets
- Accessories
- Tops
This structure makes it easy for shoppers to drill down and find the specific type of clothing they‘re looking for.
Be Selective with Your Categories
It can be tempting to create a category for every possible topic, but resist the urge to go overboard. Having too many categories can actually make your content harder to navigate and appear cluttered.

Image source: Kinsta
Instead, aim for a manageable number of categories that cover your site‘s most important themes. A good rule of thumb is to have no more than 10-15 top-level categories, with subcategories as needed.
According to Kinsta‘s analysis of WordPress categories, the majority of sites (over 75%) use 12 or fewer categories.
Fewer, well-organized categories are better for both users and search engines. So if you find yourself with too many similar categories, consider merging or consolidating them.
Optimize Categories for Search Engines
In addition to being user-friendly, your categories should be optimized to help search engines understand and rank your content. Here are a few tips:
- Use relevant keywords: Include important keywords in your category names and descriptions, but avoid keyword stuffing. Make sure the keywords fit naturally.
- Provide unique content: Give each category its own description and consider adding some introductory text to the category archive pages. This helps them stand out as valuable pages in their own right.
- Use schema markup: Structuring your category pages with schema markup helps search engines parse the content and display it in rich results. The Yoast SEO plugin can automatically add the appropriate schema for you.
- Build internal links: Link to your most important category pages from other relevant posts and pages on your site. This helps search engines understand which categories are most central to your site.
- Noindex empty categories: As mentioned earlier, if you do decide to display empty categories, it‘s a good idea to noindex those archive pages. This prevents search engines from indexing low-value pages that may be seen as "thin content".
By taking the time to optimize your categories for both users and search engines, you‘ll make your WordPress site that much stronger.
Wrapping Up
Phew, we‘ve covered a lot! To recap, displaying categories strategically in WordPress can have a significant impact on your site‘s usability, organization, and SEO. Whether you want to show categories only if they have posts or hide some categories completely, you now have the tools and knowledge to do so.
Remember, you can use code snippets to modify the wp_list_categories() arguments and show or hide categories across your site. Or you can take advantage of helpful plugins like Reveal Empty Categories, Ultimate Category Excluder, and Category Visibility to manage things from the WordPress dashboard.
Think about which approach makes the most sense for your particular site and content. In most cases, hiding empty categories is the right move and will provide a cleaner experience for visitors. But there are times when displaying empty categories can also work well, like if you‘re developing a new site or want to highlight topics you plan to cover.
No matter which route you take, keep the best practices we covered in mind. Use clear category names, create a logical hierarchy, and optimize your categories to make them easy for both humans and search engines to navigate.
Now you have the ultimate guide to showing and hiding WordPress categories! I hope this has given you a solid understanding of how categories work under the hood and how to bend them to your will.
If you have any other questions about working with categories in WordPress, feel free to leave a comment. I‘m always happy to chat about all things WordPress.
Happy categorizing!
