We have a site with categories and subcategories.
If anybody navigates to a content belongs to a subcategory the url will have the following form: domain/main-category/sub-category/mycontent/
But we need another form: domain/main-category/mycontent
where mycontent
belongs a subcategory inside main-category
, but we don’t want the subcategory to be displayed in the URL.
Is there any possible solution for this?
If you go to Settings->Permalinks you should be able to set the tag/category base URL rules which should solve this problem.
Or, use some sort of plugin to do what you want. This one came up first on Google: http://wordpress.org/plugins/custom-permalinks/
try the following code :
Yes you can! Just select the primary category of the post.
I am sorry that this screenshot is german, but it is pretty self-explaining. Here we have a main group “Party” with a subgroup “Rezepte”. We can set the url to only “/party” by selecting that category as a new main.
The screenshot is taken from WordPress 5.8
Also make sure your permalink structure (Settings->Permalinks) is set to
/%category%/%postname%
!You can rewrite you
.htaccess
if you are familiar with this.Add the below line and try it:
This should work fine. Add this to your end of functions.php file.
examplesite.com/wp-content/theme/yourtheme/functions.php <<- right there.
If you’re using WP Category permalink plugin then disable it and use the following as your permalink custom structure
/%category%/%postname%/
That’s it
Just go to:
and choose
/%category%/%postname%/
That should do it.!