How to Include Category and SubCategory in WordPress URLs

Categories and Subcategories allow you to organise content on your website, so your readers can quickly find what interests them.

Sometimes you might want to have the category as well as subcategory in the URL.

For example: http://yoursite.com/news/international/politics-today

In this example, news is the category and international is a subcategory. Including categories and subcategories in the WordPress URL is a good idea for a couple of reasons.

  1. It makes a clean URL to read and helps people understand the context from the URL itself. For example, from the above URL, a user can easily understand that the article points to the international news on your news website.
  2. Search engine optimisation. Your site gets better hits and visibility in Google and other search engines for relevant keywords.

If you use WordPress’ default URL structure, you will not get the category and subcategory in it. Here’s how you can modify the structure to include them.

Click on Settings and then Permalinks page from your WordPress menu.

  1. Click on Custom Structure option under the Permalink Settings. This is where we will configure the URL.
  2. For what we want to achieve, enter the /%category%/%postname%/ in the field next to the Custom Structure. Click on Save Changes.That’s all. WordPress will now start adding categories and subcategories for a post in the URL.

    To see this in action, create a new post and assign it a category as well as subcategory. Once you do this and save the post, you would be able to see the category and subcategory inside the URL.

    Using Multiple Categories/Subcategories

    If you categorise your blog posts into multiple categories or subcategories, then WordPress does not pick them all up for the URLs. It will only pick up one category and one subcategory for the URL. In case there was no subcategory chosen, then it will show the parent category.

    WordPress selects categories alphabetically. For example, you have an article filed under Google, Technology categories, then the URL would be:

    http://yoursite.com/google/google-launches-new-device

    However, if you filed under Google, which had a Technology subcategory, then the URL would be:

    http://yoursite.com/google/technology/google-launches-new-device

    If you selected a subcategory, but did not specifically select a category, WordPress will automatically put the parent category in the URL.

    It can be possible that you selected a category, subcategory and a sub-sub category for an article. In this case, WordPress would include the category, subcategory, sub – subcategory to the URL as well.

    This is how the URL would look like :

    http://yoursite.com/google/technology/devices/google-launches-new-device

    Using detailed category and subcategory in URLs is a good way to enhance the readability of the URL, as well as increase SEO for your website.

Was this article helpful?

Leave A Comment?