Are you wondering how to include the category and subcategory in WordPress URLs?
Categories and subcategories allow you to sort content on your website. They also allow your users to easily browse the topics they are most interested in.
In this article, we will show you how to include category and subcategory in WordPress URLs.
Including the Category to SEO-Friendly URLs in WordPress
Categories are typically used for broader topics and can have subcategories. You can see our guide on how to add categories and subcategories in WordPress.
However, if you are using the default WordPress URL structure, then your categories and subcategories are not included in the post URLs.
Some websites use categories and subcategories in WordPress URLs for their posts.
For example, at WPBeginner, we include categories in the URLs of our posts like this:
Some WordPress websites that use subcategories display both parent and child categories in the URL:
In this example, news is the parent category, and national is the child category.
Including a category or subcategory in your post URLs makes them more user-friendly. It matches the breadcrumb navigation on your site, and it includes more keywords and text, which is also helpful for SEO.
Having said that, let’s see how to easily add categories and subcategories in WordPress URLs.
Adding Category and Subcategory in WordPress Post URLs
First, you need to visit the Settings » Permalinks page in your WordPress admin dashboard. There you need to click on the ‘Custom Structure’ option in the Common Settings area.
Next, you need to add
/%category%/%postname%/ in the field next to Custom Structure.
After that, don’t forget to click on the ‘Save Changes’ button to store your settings.
That’s all. WordPress will now start including the category and subcategory in WordPress URLs. You can see this in action by editing a post or creating a new one.
Just assign that post a category (and subcategory if you use them) and click on the ‘Update’ button.
You will notice the category and subcategory included in the post’s permalink.
Using Multiple Categories or Subcategories
Let’s imagine you sort your WordPress blog posts into multiple categories or subcategories.
WordPress will only include one category and one subcategory in the URL. If you didn’t choose a subcategory, then it will only show one parent category.
WordPress chooses the category alphabetically. For example, if you file a post using the ‘Apple’ and ‘Technology’ categories, then WordPress will include ‘apple’ in the URL because it comes first in alphabetical order:
If you file a post in ‘Apple’ and a subcategory under that called ‘Technology’, then it will include both of them in the URL:
If you selected a subcategory but didn’t specifically select a parent category, then WordPress will still include the parent category in the URL.
Another scenario is when you have a parent category, a subcategory, and a sub-subcategory. WordPress will include all three of them in the URL:
We hope this article helped you learn how to include a category and subcategory in WordPress URLs. You may also want to see our step-by-step WordPress SEO guide for beginners and our expert picks for the best WordPress SEO plugins and tools.