Recently one of our readers asked us how to include 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 Category to SEO Friendly URLs in WordPress
WordPress comes with two built-inΒ taxonomiesΒ to sort your content. They are calledΒ categories and tags.
Categories are typically used for more broader topics and can have subcategories. 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 pluginthemehub we include category in the URLs of our posts like this:
https://www.pluginthemehub.com/plugins/7-best-wordpress-backup-plugins-compared-pros-and-cons/
Some websites that use subcategories display both parent and child categories in the URL.
http://example.com/news/national/article-title-here/
In this example, news is the parent category and national is the child category.
Including category or subcategory to 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 category and subcategory in WordPress URLs.
Adding Category and Subcategory in WordPress Post URLs
First, you need to visitΒ Settings Β» PermalinksΒ page in your WrodPress admin. There you need to click on the βcustom structureβ option under common settings area.
You will notice category and subcategory included in the postβs permalinks.
Using Multiple Categories or Subcategories
Letβs suppose you file your 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 in Apple and Technology categories, then WordPress will include apple in the URL because it comes first in alphabetical order.
http://example.com/apple/article-title-here/
If you file a post in βAppleβ and a subcategory under that called βTechnologyβ, then it will include both of them in the URL.
http://example.com/apple/technology/article-title-here/
If you selected a subcategory but didnβt specifically select parent category, then WordPress will still include parent category in the URL.
Another scenario is when you have a parent category, subcategory, and a sub-subcategory. WordPress will include all three of them in the URL.
http://example.com/apple/technology/events/article-title-here/
We hope this article helped you learn how to include category and subcategory in WordPress URLs. You may also want to see our step by stepΒ WordPress seo guide for beginners.
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.