In WordPress, your posts can be organized into different categories and tags. You can even create subcategories for further organization.
Using categories and subcategories can help your readers find the content they’re most interested in and improve your website’s SEO rankings.
Over the past 16 years, we have effectively organized our posts into categories and subcategories across all our websites to improve site navigation for our readers. This has improved our accessibility and contributed to higher search engine rankings by making our content more user-friendly.
In this article, we’ll show you how to easily 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.
Note: 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.
However, 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 subcategories. Then ‘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 the ‘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.
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.
First, if the sidebar isn’t showing when you’re editing a post, you’ll need to click on the gear icon on the top right.
Then, in the block panel on the right-hand side, open up the Categories tab.
You will see different categories that you’ve already created.
However, to create a new category, you can simply click the ‘Add New Category’ link.
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, simply 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 and give them a description. See how 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 the settings panel and scroll down to the Categories tab.
Next, click the ‘Add New Category’ option and type in the name of your child category. Then 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 of 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 is used to group multiple types of content together, like this:
Here, News is a category, with the Announcements as child categories.
Categories on the same level within a parent category are sometimes called ‘sibling’ categories. For instance, the Announcements and SEO Tools 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:
https://example.com/category/united-states/new-york-city/
This is meaningful and helps search engines and visitors understand what your page is about. You also get a chance to add keywords to your URL. Keywords help people find content on search engines.
WordPress also allows you to easily change the /category/ prefix of your category URLs. You can even remove it completely if you want.
Simply go to the Settings » Permalinks page from the WordPress admin panel and scroll down to the ‘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.
This is why some website owners prefer to remove the word ‘category’ from their WordPress category archive pages’ URLs. You can easily do this by using the All in One SEO plugin, so your category URLs look like this:
http://example.com/united-states/new-york-city/
Simply go to the Search Appearance menu for AIOSEO and then select the Taxonomies tab. Under the Advanced settings for Categories, you will see the option to remove the category base prefix.
Alternatively, you can also use the FV Top Level Categories plugin. Simply install the plugin and it will remove the word ‘category’ from your category archive pages’ URLs.
Important: If you decide to change the 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 block 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 block already in place. If not, then you can click the ‘+’ button and add a ‘Category’ block to your widget area.
By default, the widget will show all your categories in a flat list, in alphabetical order.
Here’s a preview of how they looked on our test website:
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 enable the ‘Show hierarchy’ option in the widget settings like this. Don’t forget to click the ‘Update’ 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 block, you can also create custom category menu links using the WordPress navigation menu. After that, you can add that menu to your header menu, sidebar, footer, or other menu locations.
Bonus: Display Subcategories on Category Pages in WordPress
Once you have added subcategories to your website, you can display them on your category pages. This will make it easier for users to navigate your content and may boost traffic.
To display subcategories, you must add the following custom code to your category.php file. You can find this folder in your theme files.
<?php
if (is_category()) {
$this_category = get_category($cat);
}
?>
<?php
if($this_category->category_parent)
$this_category = wp_list_categories('orderby=id&show_count=0
&title_li=&use_desc_for_title=1&child_of='.$this_category->category_parent.
"&echo=0"); else
$this_category = wp_list_categories('orderby=id&depth=1&show_count=0
&title_li=&use_desc_for_title=1&child_of='.$this_category->cat_ID.
"&echo=0");
if ($this_category) { ?>
<ul>
<?php echo $this_category; ?>
</ul>
<?php } ?>
Once you do that, just visit any category page on your website where you will notice a list of its subcategories that users can browse.
For details, see our tutorial on how to display subcategories on category pages in WordPress.
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 custom taxonomies in WordPress and our guide on how to add quicktags in WordPress comment forms.
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.
kzain
I was struggling to organize my blog posts effectively. This post made it super easy to create categories and subcategories. The explanation of how they can improve SEO was really helpful too. Thanks for sharing!
Atul Tanna
I have a Buying Guide, Review, and Categories and Under Categories I have several sub categories
When I Review Amazon Products I would like them to appear under Reviews and at te same time time I would like them to appear in one of the sub categories How do I get started and what do I do
Thanks
WPBeginner Support
Unless your theme specifically hides them, your category pages should include any subcategories in the list of posts. You can create the category pages by linking to your category in your menu and our guide below should help create your menu!
https://www.wpbeginner.com/beginners-guide/how-to-add-navigation-menu-in-wordpress-beginners-guide/
Admin
Alaba
Hi, my site has some categories that don’t have any parent category. However, these were created a long time ago. Can I just assign them one?
WPBeginner Support
You can but if you have any posts under the categories, be sure to redirect any posts that had their URLs changed
Admin
Ayo
Hi, How can I have a parent category that covers all the posts of its subcategories like the one on this web (https://www.wpbeginner.com/blog/)?
WPBeginner Support
That would be your posts/blog page that you can set under Settings>Reading
Admin
Imran khan
When using child categories, should I check the parent category also checked, or keep it unchecked?
WPBeginner Support
If you mean when adding a post to the category, you would only need to check the child category
Admin
Imran khan
I have my permalink structure set to “/%category%/%postname%/” and I want to show the parent category in my URL.
1. If I checked the child category my post URL’s are showing: “www.my-site.com/parent-cat/child-cat/post-name/”
2. If I checked both child and parent categories, my post URL’s are showing: “www.my-site.com/parent-cat/post-name/” that I want. So now should I check the parent category also checked, or keep it unchecked? If i checked both then it would not be an issue to have duplicate content that will negatively affect on SEO.
WPBeginner Support
Your URLs are like that as your parent category would be used first. It should not affect your SEO but you can use both categories if you wanted. Otherwise, we would recommend taking a look at the recommendations from our article below:
https://www.wpbeginner.com/wp-tutorials/how-to-change-the-category-base-prefix-in-wordpress/
Terry
Can subcategories be used for products?
WPBeginner Support
Yes, as long as your eCommerce plugin allows.
Admin
Sade
Hi,
I have made my catergory showing at the top a drop down, but when I put category in my primary sidebar when I click it says ‘select category’ and doesn’t show my sub categories. How do I fix this?
Thanks
WPBeginner Support
You would normally need to manually add subcategories if we’re understanding what you’d want correctly.
Admin
Ebi
Hi
Can I generate multiple articles for the main category without selecting a subcategory for it (with a few subcategories), is this SEO desirable?
WPBeginner Support
You can have multiple posts in one category if you wanted and not use subcategories, it would depend on the overall organization of your site for how useful it would be and if it would have any SEO effect.
Admin
usman
hay i need to know how i display sub-category show in menu when i add new show auto into the menu
WPBeginner Support
For customizing your menu, you would want to take a look at our guide below:
https://www.wpbeginner.com/beginners-guide/how-to-add-navigation-menu-in-wordpress-beginners-guide/
Admin
Candy
I have six categories on my homepage. When you click the image on the homepage, it takes you to that category page. I am having an issue with blog posts. How do I get the blog post to automatically appear on the correct category page? I’m been doing this manually and I know there has to be another way. Thanks in advance!
WPBeginner Support
You should be able to link to the category page for WordPress to automatically list the posts in a category. You can get the link to your category page by adding a category to your menu. You should not be manually creating your category pages.
Admin
Stef
You mentioned if you don’t attach the item to the parent and only the child that it wouldn’t show up in the parent. This is incase you don’t want duplicate content.
If left attached to both would this create an SEO issue of having duplicate content then? I know Google frowns upon duplicate content, but you didn’t say.
Thanks in advance.
WPBeginner Support
It should not cause a duplicate content issue either way.
Admin
Muhammad Salman
Good. It helped me a lot thanks wpbeginner
WPBeginner Support
You’re welcome, glad our article was helpful
Admin
Julie
Thanks,
I was told I was creating my categories incorrectly as they had the word ‘category’ in the URL. I read several posts on how to create categories and yours was the only one explaining this.
That said, how bad is it to have this? I hate to add in yet another plugin. It really doesn’t bother me…unless it should for some reason.
Julie
WPBeginner Support
There is a large amount of personal preference as search engines don’t specify their preference other than being easy for users to understand. You can always update your category names if you wanted but it is not a hard requirement. For adding more plugins, for the most part, you shouldn’t worry. For our guide on plugins you would want to take a look at our article here:
https://www.wpbeginner.com/opinion/how-many-wordpress-plugins-should-you-install-on-your-site/
Admin