I have standard posts and custom posts utilised on my site. Basically for standard and custom posts we want the following.
parent post category e.g.: âblogâ
then sub categories to this parent category. So e.g.:
Blog (parent Category)
News (Sub Category)
LatestNewsPostOne
events (sub category)
LatestEvnntssPostOne
So posts can live in any or all of these categories. If you visit the âblogâ category you will have the following permastructure:
domain.com/blog
If you visit ânewsâ category you will have the following permastructure:
domain.com/blog/news
However when you visit âLatestNewsPostOneâ you would have the following permastructure:
domain.com/blog/LatestNewsPostOne
So in the last example you will notice that once you click on an individual post to open it. the subcategory disappears from the url. Currently my site leaves in the subcategory which I donât want.
Does anyone know of any solution to implement this on a WordPress site?
I’ve figured it out. Below is my code to get rid of the subcategory slug from blog post permalink URL, I added the following to my functions.php file in the theme folder: