Including classes and sub-categories in WordPress

Recently a reader asked us how to create subcategories in WordPress.

In WordPress, your posts can be divided into different categories and tags. You can even create sub-categories for further organization.

It is important to use categories and subcategories properly so that you can help your readers find the content that they are most interested in. Proper categorization of content can also improve your website’s SEO ranking.

In this article we will show you step by step how to add categories and subcategories in WordPress.

Understanding Parent and Child Categories in WordPress

Categories are a powerful tool. They’re not just a way to sort your content. They will also help you develop an appropriate site structure that is meaningful and semantic. This is great for your WordPress SEO.

Important: If you’re unsure about the difference between categories and tags, check out our guide to categories and tags. This explains why categories and tags are different and how to use them properly.

Now you might be wondering why and when someone needs to use sub-categories (sub-categories) on their WordPress website.

Suppose you are creating a travel blog for various destinations around the world. You may want users to be able to find items by country and city.

For example, you might have an article on the best water parks in the United States. It would make sense to use “USA” as the category for this post.

Or, you might have articles on the best restaurants in New York City, Los Angeles, Chicago, and more.

Here you can use subordinate or sub-categories. “United States” can be a parent category and cities can be child categories.

Child and parent categories in WordPress

A post that was filed under a subordinate category does not have to be filed under the superordinate category. In our example we would have left “USA” deactivated and simply put the post in the “New York City” category.

If you submit a post under the child category but not the parent category, your post will only appear on the archive pages of the child category. This is especially useful when you want to avoid duplicate content.

Let’s take a look at how to add both regular and sub categories in WordPress.

Adding a category in WordPress

You can easily add a new category in WordPress when writing a post. In the document window on the right, open the Categories tab.

You can then simply click the “Add New Category” link to create your new category.

Adding a new category in the document settings of a post

Once you click the link, two new fields will appear for you to add your category. For a regular category, you don’t need to select anything from the Parent Category drop-down list.

The fields for adding your new category are now visible

After you’ve entered the name for your category, click the “Add New Category” button.

The check box for this category is then automatically checked for your current post. You can turn it off if you want.

The new category has now been added to your site

You can also add a new category without editing a post.

Just go to Posts »Categories and add your new category. This is useful when you want to create all of your categories before adding any content.

You can also use this method to edit the slug (url) for your categories. Here you can also delete and rename categories. You can even give them a description. Learn how to add SEO keywords and descriptions in WordPress.

Adding a new category under Posts - Categories in WordPress

Adding a child category (sub-category) in WordPress

You can add and edit child categories just as you added your parent categories.

When editing a post, open the Categories tab and enter the name for your subcategory. From the drop-down list, select the category that you want to use as the parent.

Adding a new child category when creating a post

Likewise, you can go too Posts »Categories add subcategories. Simply enter the name for your child category and select the parent category from the drop-down menu.

Add a new sub-category under Posts - Categories

Your child categories can also have their own child categories if you wish. For example, we could choose to develop a category structure that uses continents, countries, and cities like this:

A list of categories of children with their own children

Here, Europe is one category, with the UK and Spain being children’s categories. These then have their own child categories: York and London for the United Kingdom and Barcelona and Madrid for Spain.

Categories at the same level within a parent category are sometimes referred to as “sibling” categories. For example, the UK and Spain are sibling categories here.

Categories can only have one parent. You cannot add a sub-category under two different parent categories.

SEO advantages of the category-based site structure

Your category URLs will look something like this:

http://example.com/category/united-states/new-york-city/

This makes sense and helps search engines and visitors understand what your page is about. You can also add keywords to your URL. Keywords can help users find content on search engines.

WordPress also makes it easy to change the / category / prefix of your category urls. You can even remove it entirely if you want.

Just go to Settings »Permalinks Page and scroll down to the ‘Category Base’ section.

Change category base section

Here you can enter the prefix you want to use and click the Save Changes button to save your changes.

The “Category” prefix in your category URLs is of no use to your SEO. You may want to get rid of it by installing the FV Top Level Categories plugin. Just install the plugin and it will remove the word “category” from the URLs of your category archive pages. Instead, they look like this:

http://example.com/united-states/new-york-city/

Important: If you want to change the category base on an existing WordPress site, you’ll need to set up redirects to avoid 404 errors for search engine visitors. For more detailed instructions, check out our guide on changing the category base prefix in WordPress.

Show categories and sub-categories in the WordPress sidebar

You can add a widget to your WordPress sidebar or footer to display a list of categories. Go to in your WordPress dashboard Appearance »Widgets.

Adding a new widget to your sidebar

If you haven’t changed your widgets from the ones that WordPress places there by default, the Categories widget should already be there. If not, you can drag and drop it from the list of available widgets on the left.

Drag and drop the Categories widget onto your sidebar

By default, the widget displays all of your categories in a flat list in alphabetical order:

A flat list of categories

Tip: Categories will only appear in the list if you have assigned at least 1 published post to them.

You can change it to show the child categories (sub-categories) under their parent categories if you want. Just check the “Show Hierarchy” box in the widget like this. Don’t forget to hit the save button.

Check the box

Your site should now show your parent categories with the child categories nested below them.

A hierarchical list of categories in WordPress

Tip: If your changes aren’t showing up in the sidebar, you may need to clear your WordPress cache.

In addition to the standard categories widget, you can also create custom category menu links from the WordPress navigation menu. After that, you can add this menu in your header menu, sidebar, footer, or other menu items.

We hope this tutorial has helped you learn how to add categories and child categories in WordPress. You might also want to check out our article on How to Create an Email Newsletter to Boost Your Website Traffic and our comparison of the best WordPress page builders to create custom layouts.

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

Comments are closed.