Recently, a reader asked us how to create subcategories in WordPress.
In WordPress, your posts can be organized into different categories and tags. You can even create subcategories for further organization.
It's important to use categories and subcategories correctly, so you can help your readers find the content they're most interested in. Proper content categorization can improve your website's SEO rankings as well.
In this article, we'll show you how to add categories and subcategories in WordPress, step by step.
Understanding Parent and Child Categories in WordPress
Categories are a powerful tool. They're not just a way to sort your content. They also help you develop a proper site structure that is meaningful and semantic. This is great for your WordPress SEO.
Important: If you're not clear about the difference between categories and tags, take a look at our guide on categories vs tags. This explains why categories and tags are different, and how to use them correctly.
Now you might be wondering why and when would someone need to use child categories (subcategories) on their WordPress website?
Let's say you're creating a travel blog for different destinations around the world. You might want users to be able to find articles by both country and city.
For example, you might have an article about the best waterparks in the United States. It would make sense to use ‘United States' as the category for that post.
But you might also have articles about the best places to eat in New York City, Los Angeles, Chicago, and more.
This is where you can use child or sub categories. ‘United States' can become a parent category, and the cities can become child categories.
A post filed under a child category doesn't need to also be filed under the parent category. In our example, we could have left ‘United States' unchecked and just put the post in the ‘New York City' category.
If you file a post under the child category but not under the parent category, then your post will appear only on the archive pages of the child category. This is particularly helpful when you want to avoid duplicate content.
Having said that, let's take a look at how to add both regular categories and child categories in WordPress.
Adding a Category in WordPress
You can easily add a new category in WordPress when writing a post. In the Document panel on the right hand side, open up the Categories tab.
Then, you can simply click the ‘Add New Category' link to create your new category.
Once you click the link, two new boxes will appear where you can add your category. For a regular category, you don't need to select anything from the Parent Category dropdown.
Once you've typed in the name for your category, click the ‘Add New Category' button.
The box for that category will then be automatically checked for your current post. You can uncheck it if you want.
You can also add a new category without editing a post.
Simply go to Posts » Categories and add your new category. This is handy if you want to create all your categories before adding content.
This method also lets you edit the slug (URL) for your categories. You can delete and rename categories here, too. You can even give them a description. See how to to add SEO keywords and descriptions in WordPress.
Adding a Child Category (Sub Category) in WordPress
You can add and edit child categories in exactly the same way you added your parent categories.
When you're editing a post, open up the Categories tab and type in the name for your child category. Select the category that you want to use as the parent from the dropdown list.
Similarly, you can also go to Posts » Categories to add child categories. Just type in the name for your child category and select the parent category from the dropdown menu.
Your child categories can also have their own child categories, if you want. For instance, we might decide to develop a category structure that used continents, countries, and cities, like this:
Here, Europe is a category, with the United Kingdom and Spain as child categories. These then have their own child categories: York and London for the United Kingdom, and Barcelona and Madrid for Spain.
Categories on the same level within a parent category are sometimes called “sibling” categories. For instance, United Kingdom and Spain are sibling categories here.
Categories can only have one parent. You can't add one sub-category under two different parent categories.
SEO Benefits of Category Based Site Structure
Your category URLs will look something like this:
This is meaningful and helps search engines and visitors understand what your page is about. You also get a chance to add keywords into your URL. Keywords help people find content on search engines.
WordPress also allows you to easily change the /category/ prefix your category URLs. You can even remove it completely if you want.
Simply go to Settings » Permalinks page and scroll down to ‘Category base' section.
Here you can enter the prefix you would like to use and click on the Save Changes button to store your changes.
The ‘category' prefix in your category URLs doesn't add any benefit to your SEO. You might want to get rid of it by installing the FV Top Level Categories plugin. Simply install the plugin and it will remove the word ‘category' from your category archive pages' URLs. Instead, they'll look like this:
Important: If you decide to change category base on an existing WordPress site, then you'll need to set up redirects to avoid 404 errors for search engine visitors. For more detailed instructions, please follow our guide on how to change the category base prefix in WordPress.
How to Display Categories and Child Categories in WordPress Sidebar
You can add a widget to your WordPress sidebar or footer to show a list of categories. In your WordPress dashboard, go to Appearance » Widgets.
If you haven't changed your widgets from the ones that WordPress puts there by default, you should see the Categories widget already in place. If not, you can drag and drop it from the list of Available Widgets on the left hand side.
By default, the widget will show all your categories in a flat list, in alphabetical order:
Tip: Categories will only display on the list if you've assigned at least 1 published post to them.
You can change it to show the child categories (subcategories) beneath their parent categories, if you want. Simply check the ‘Show hierarchy' box in the widget like this. Don't forget to click the Save button.
On your site, you should now see your parent categories with the child categories nested beneath them.
Tip: If your sidebar changes don't show up, you might need to clear your WordPress cache.
Aside from the default category widget, you can also create custom category menu links using the WordPress navigation menu. After that, you can add that menu in your header menu, sidebar, footer, or other menu locations.
We hope this tutorial helped you learn how to add categories and child categories in WordPress. You may also want to take a look at our article on how to create an email newsletter to grow your website traffic, and our comparison of the best WordPress page builders to create custom layouts.
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.
The post How to Add Categories and Subcategories in WordPress appeared first on WPBeginner.