Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Blogging & content · Guide

How to Display All Categories in WordPress (Step by Step)

How to Display All Categories in WordPress (Step by Step)

Short answer

Add the Categories List block to a page, sidebar or template and turn on the option to show empty categories if you want every one listed. Developers can use wp_list_categories with hide_empty set to false, and menus can hold category links too.

Key takeaways

  • The Categories List block is the quickest way to list categories.
  • WordPress hides categories with no published posts by default.
  • Set hide_empty to false in wp_list_categories to show every category.
  • A shortcode lets you place the list anywhere.
  • Product categories need WooCommerce blocks or the product_cat taxonomy.

How do you display all categories in WordPress?

The easiest way to display all categories in WordPress is to add the Categories List block to a page, sidebar or template, then turn off the option that hides empty categories if you want every one shown.

You can also show categories with a classic widget, a menu, or a short piece of PHP using wp_list_categories() in your theme.

Which method is best depends on where you want the list and how much control you need. This guide covers each option step by step.

MethodWhere it worksShows empty categories?Skill level
Categories List blockPosts, pages, widgets, Site EditorOptionalBeginner
Classic Categories widgetClassic theme sidebarsNo by defaultBeginner
Navigation menuHeader or footer menusYes, if addedBeginner
wp_list_categories()Theme templatesOptional (hide_empty)Developer
Shortcode from a custom functionAnywhere shortcodes runOptionalIntermediate

What are categories and why list them all?

Categories are WordPress's main way to group posts by topic, and listing them all gives visitors a quick map of what your site covers.

Every post belongs to at least one category. If you never pick one, WordPress files it under the default category, which is Uncategorized unless you change it.

A full category list helps readers jump to the topics they care about. It also creates internal links to each category archive, which helps search engines find your content.

If you are new to how categories work, our guide on what categories are in WordPress explains the basics.

How do you add the Categories List block to a page?

Open the page in the block editor, click the + inserter, search for Categories, and add the block where you want the list to appear.

Follow these steps:

  1. Go to Pages and open the page you want, or create a new one.
  2. Click the + button in the top toolbar or inside the content.
  3. Type Categories and choose the Categories List block.
  4. The block shows your categories right away.
  5. Adjust the settings in the right sidebar.
  6. Click Save or Update.

The block settings let you change how the list looks:

  • Display as dropdown turns the list into a select menu.
  • Show post counts adds the number of posts next to each name.
  • Show only top level categories hides child categories.
  • Show hierarchy indents child categories under their parents.
  • Show empty categories includes categories with no published posts.

The official Categories block documentation describes each option.

Why are some categories missing from the list?

Categories usually go missing because they have no published posts, since WordPress hides empty categories by default in the block, the widget and the PHP function.

A category with only draft, scheduled or private posts counts as empty for visitors. Once you publish a post in it, it appears.

Other common reasons:

  • Show only top level categories is turned on, which hides child categories.
  • A plugin or theme filters the list.
  • You are looking at a cached version of the page.

To show every category, including empty ones, turn on the empty categories option in the block. Then clear your cache and reload.

Be careful with empty categories on a live site, though. Clicking one leads to an archive page with no posts, which is a poor experience.

Add the Categories List block to a widget area under Appearance > Widgets, or to a template part such as the footer in the Site Editor if you use a block theme.

For classic themes:

  1. Go to Appearance > Widgets.
  2. Open the sidebar or footer widget area.
  3. Click + and add the Categories List block.
  4. Choose your settings and click Update.

For block themes:

  1. Go to Appearance > Editor.
  2. Open Patterns or Template Parts and choose the footer or sidebar part.
  3. Add the Categories List block.
  4. Save the template part.

If your widget area does not appear on the site, our guide on widgets not showing covers the usual causes.

To add a new area, see adding a custom widget area.

How do you add all categories to a menu?

You can add categories to a navigation menu by choosing them in the menu editor, which suits sites that want topic links in the header.

In a classic theme, go to Appearance > Menus. Open the Categories panel on the left, click View All, tick Select All, and click Add to Menu. Then save the menu.

In a block theme, open the Navigation block in the Site Editor and add a Category link for each category you want. You can also nest them under a parent item.

Menus do not update by themselves. When you create a new category later, you have to add it to the menu by hand.

Our guide on adding sub menus in WordPress shows how to group many categories under one dropdown.

How do you display all categories with PHP?

Developers can print every category in a theme template with wp_list_categories(), setting hide_empty to false so categories without posts are included.

Add this to a template file in a child theme, not the parent theme, so updates do not wipe it:

<ul class="all-categories">
<?php
wp_list_categories( array(
    'title_li'   => '',
    'hide_empty' => false,
    'show_count' => true,
    'orderby'    => 'name',
) );
?>
</ul>

The title_li argument set to an empty string removes the default Categories heading. The show_count argument adds post counts.

The full list of arguments is in the wp_list_categories reference on the developer handbook.

If you need the categories as data rather than HTML, use get_categories() or get_terms() and loop through the results yourself.

How do you create a shortcode to list categories?

Wrap wp_list_categories() in a small function and register it as a shortcode, so you can drop the list into any post, page or widget with a short tag.

Add this to your child theme's functions.php or a code snippets plugin:

function wpl_all_categories_shortcode() {
    return '<ul class="all-categories">' . wp_list_categories( array(
        'title_li'   => '',
        'hide_empty' => false,
        'echo'       => 0,
    ) ) . '</ul>';
}
add_shortcode( 'all_categories', 'wpl_all_categories_shortcode' );

Then type [all_categories] in a Shortcode block. The echo argument set to 0 makes the function return the HTML instead of printing it, which shortcodes need.

New to shortcodes? Our guide on writing a shortcode in WordPress explains the basics.

How do you style the category list?

Give the list a CSS class, then use a few lines of CSS to remove bullets, add spacing or split the list into columns.

The Categories List block has an Additional CSS class field under Advanced. Add a class such as cat-grid, then target it in Appearance > Customize > Additional CSS or in your theme's styles.

This example splits a long list into three columns:

.cat-grid {
    columns: 3;
    list-style: none;
    padding-left: 0;
}
.cat-grid li {
    margin-bottom: 8px;
}

The CSS columns property is well supported in modern browsers. MDN has a simple guide to multi-column layout if you want to adjust it.

How do you show WooCommerce product categories instead?

Product categories are a separate taxonomy, so the normal Categories List block will not show them; use WooCommerce's product category blocks or shortcodes instead.

WooCommerce includes blocks such as Product Categories List for this job. You can also use the product_cat taxonomy with wp_list_categories() by passing 'taxonomy' => 'product_cat'.

Our guide on showing product categories in WooCommerce walks through each option.

Should all category pages be indexed by search engines?

Category archives with real, useful posts are worth indexing, but empty or near-empty category pages are usually better left out of search results or merged.

Thin category pages add little value and can clutter your site in search. If you want to keep one but hide it from Google, add a noindex tag with your SEO plugin.

Google explains how noindex works in its guide to blocking search indexing.

For a fuller strategy, read our guide on handling category and tag pages for SEO. It covers when to index, noindex or merge archives.

Frequently asked questions

Why does my category list not show all categories?

WordPress hides categories that have no published posts. Categories with only drafts or scheduled posts are hidden too. Turn on the show empty categories option in the block, or set hide_empty to false in code, and check that top level only is switched off.

How do I show categories as a dropdown in WordPress?

Add the Categories List block and turn on Display as dropdown in the block settings. Visitors then pick a category from a select menu. In code, you can use wp_dropdown_categories to output the same kind of menu inside a theme template.

Can I show post counts next to each category?

Yes. Turn on Show post counts in the Categories List block, or pass show_count set to true to wp_list_categories. The number only counts published posts, so drafts and private posts are not included in the total.

How do I exclude a category from the list?

The block has no exclude setting, so use code. Pass the exclude argument with a comma separated list of category IDs to wp_list_categories. You can find each ID by hovering over the category name under Posts, Categories and reading the link.

Do categories update automatically in menus?

No. A menu only contains the items you added. When you create a new category, add it to the menu by hand. The Categories List block and wp_list_categories do update automatically whenever categories change.

Sources

  1. Categories block WordPress.org
  2. wp_list_categories() WordPress Developer Resources
  3. columns MDN Web Docs
  4. Block search indexing with noindex Google Search Central

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.