Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Include Category and Subcategory in WordPress URLs

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.

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 WPBeginner we include category in the URLs of our posts like this:

https://www.wpbeginner.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.

Adding category to WordPress post URLs

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 category and subcategory in WordPress URLs. You can see this in action by editing a post or creating a new one.

File that post under a category (and subcategory if you use them) and click on the update button.

Category and subcategory in blog post URL

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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

39 CommentsLeave a Reply

  1. Is it a disadvantage to using categories in URL? like example.com/plugin/best-plugin/. in this case plugin uses 2 times. is this URL looks spammy?

    • You would want to try avoiding looking spammy with your choice of title but it is not a disadvantage to use categories n your URL.

      Admin

  2. Important note: To get URL structure like: /category/child1/child2/POSTNAME then ONLY select “child2” as the post category when editing the post. WordPress will automatically add all parent categories to the URL. Took me a while to figure that out.

  3. Is there a way to add hierarchy to parent categories? If a post has two categories how can I chose which category is used in the URL.

    As you say in your article, default is alphabetical.

    For example I have a post categorised “Fruit” and “Vegetable” with the permalink set to show /%category%/%postname%/.

    The URL shows website.com/Fruit/postname but I want it to use website.com/vegetable/postname.

    • In those situations, you may want to look into how your categories are organized to see if tags may be what you need more than categories for some organizations. Normally posts shouldn’t be in multiple categories.

      Admin

    • By default, pages don’t have categories so they wouldn’t be included in the page options.

      Admin

    • You answer is valuable for me, because I read all the post but not permalink not work fine on my side, when I applied your suggestion I got answer of my question.
      Once again thankyou very much,

  4. I am unable to see subcategory in any posts.

    I am facing issue while creating a post name. How can Icreate a URL like this: site/destinations/europe/norway/post-name

    I have the page to create a URL like above is it only possible if I create a page or with post name also can we create?

    site/destinations/europe/norway/

    • If I’m understanding the question correctly, you don’t need to create a page at the second link’s location as that would be your subcategory’s page listing the posts in that subcategory.

      Admin

  5. Adding /%category%/%postname%/ to the permalink structure breaks the pagination for some reason. Anyone else facing this?

    • There are multiple possible reasons pagination could not be working, you may want to check with your specific theme’s support or reach out to us using our contact form for which would likely fix the issue.

      Admin

  6. How did you do to link your subcategory menu pages to a clean url: YOURSITE.COM/SUBCATEGORY? without the YOURSITE.COM/CATEGORY/SUBCATEGORY?
    I don’t know how to delete the parent category from the subcategory URL on my site…

    • We don’t have a simple recommended method at the moment. If you want to remove reference to the parent category, should that category be a child category?

      Admin

  7. I have an issue. I am using Custom Structure to display category name before the post name ( /%category%/%postname%/ ). It is working fine when I am logged in but after log out It doesn’t display category name in url.

    The above issue in in chorme browser. In firefox it is working fine.

    Please help!

  8. Yeah.. we all know this information.. you see %category% and it is obvious what it does. But Thanks….
    WHAT I WAS LOOKING FOR is code as in rewrite rules for my themes functions file..

  9. Hi !
    Trick works well for a blog post / category.
    but what about woocommerce ? ay idea ?
    Even when you add this in permalink structure, WC show the main-category/product-name even if there 2 or 3 sub categories
    This is really annoying,
    Any idea?
    Thank you
    Jean-Charles

  10. This is great, but how would I go about having multiple URLs for the same post with multiple categories? So if I go from 1 category the URL is for that category and if I go from another it is that category?

    Thanks

  11. Won’t this cause duplication problems? How do you make it so the parent category doesn’t open to an archive page?

    Like as an example – Main topic Music and then have a subcategory called popmusic…..

    Music ( Not Clickable )
    Pop Music ( Clickable and rediects to your posts associated with that sub categories)

    My issue with this is people clicking the parent categories and getting redirected to a page with no post associated with it because you don’t want to have duplicate content or a post in music & pop music

  12. Why Woocommerce do not support Subcaregories in permalinks?
    Google and other browsers recommed clean URL’s. And woocommerce Category slug can not be removed unless you pay $119 Usd for a plugin that does the trick.
    Is there another way to achieve these two issues?

  13. Thanks for this post. Its working for me. The only thing doesn`t work is when i try to list news by a subcategory

    Eg. mydomain.com/categorybase/subcategory/nameofnew/

    this works showing me the blog post, but if i want to list all posts of this subcategory like this

    mydomain.com/categorybase/subcategory/

    does’nt work.

    Any ideas how to fix it?

    Thanks in advance.

  14. HI,
    I have added categories and tags in my pages. Now how do i add categories in pages permalink?
    Please suggestion will be highly appreciated.
    Thanks

  15. This solution ONLY works if you select the subcategory in the post/page category list. If you have both the parent and the subcategories checked, then the parent category is the only one that shows. For those of us using Woocommerce, this messes with the related products. If you select just the subcategory, then you won’t see any related items from the parent category. If you select them both, then you’re back to dealing with not having the subcategory listed in your URL. Been looking for a simple solution to cover both needs.

    • Have you found a solution? We have the same exact problem right now. This is quite annoying and we don’t know what to do about it.
      Any ideas or solutions are appreciated!

  16. Hello,
    that´s a really nice post. I am wondering if I change it now will change my past one as well? If yes I would had to redirect all links right?

    Thanks a lot

  17. I’m confused and could use some help.

    Specifically, I am developing an ecommerce site that is composed of mostly PAGES. (NOT using woocommerce or another e-commerce platform, but building out my own gravity form for each product page).

    I want the product category to be in ALL my PAGE URL’s, but as you know, wordpress out of the box doesn’t enable assignment of categories and tags to PAGES (wish it did). One alternative would be to use one of the plugins I found that could enable this. The other is to simply use the product category name in the SLUG (part of the permalink I can create on the product page). I could also create a page for each product category and include a gallery showing each product item that belongs to that category with a link to its specific page, or, I could skip the product category page altogether and assign the “#” in front of the category name when I create the menu, so that the category name would appear but not be an active link to any category page. I could get involved in creating a “custom post type” for my product pages which would enable them to be assigned a category and tag, much like the woocommerce product “pages” are setup (don’t know much about how to do that but would like to), etc.

    Also, the permalink settings effect URL’s for both pages and posts…correct ?

    REALLY appreciate a followup post from you that deep dives into helping people like me who are using wordpress for their ecommerce site but not using one of the out of the box ecommerce platforms.

    thankyou

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.