# How to include the category in the URL?

**URL:** https://discourse.roots.io/t/how-to-include-the-category-in-the-url/18501
**Category:** general
**Tags:** sage
**Created:** 2020-06-19T18:34:40Z
**Posts:** 3

## Post 1 by @Fernando_Jimenez — 2020-06-19T18:34:40Z

So i have a post type called knowledge base [http://www.domain.com/knowledge\_base/](http://www.domain.com/knowledge_base/)  
and i am going to have posts under categories. So it would look like `http://www.domain.com/knowledge_base/category1/hello`  
and  
`http://www.domain.com/knowledge_base/category1/helloagain`

the thing is that if i click go to my first post, lets say “random\_post” that belongs to the category “Category 1”

instead of seeing  
[http://www.domain.com/knowledge\_base/category1/random\_post](http://www.domain.com/knowledge_base/category1/random_post)  
It says  
[http://www.domain.com/knowledge\_base/random\_post](http://www.domain.com/knowledge_base/random_post)

Where can you change it so it includes the category on the URL?

Also how would you do the blade file for the categories? would it be category-slug.blade.php?

---

## Post 2 by @alwaysblank — 2020-06-19T18:43:18Z

If you want to make custom urls, you’re going to need to dig into WordPress’s Rewrites API. This post (though old) has a pretty decent walkthrough for how that works: [https://www.pmg.com/blog/a-mostly-complete-guide-to-the-wordpress-rewrite-api/](https://www.pmg.com/blog/a-mostly-complete-guide-to-the-wordpress-rewrite-api/) The short version is that you have to tell WordPress how to parse particular URL segments into query terms it can understand.

As for the blade file, look at the hierarchy and determine what filename matches the endpoint you want: [https://developer.wordpress.org/themes/basics/template-hierarchy/](https://developer.wordpress.org/themes/basics/template-hierarchy/)

---

## Post 3 by @system — 2020-07-31T18:39:05Z

This topic was automatically closed after 42 days. New replies are no longer allowed.
