I would like to adjust the permalinks of my wordpress site without using a plugin. I want to get rid of “/category” and “/tag” while adding a prefix “/blog” to all blog related sites (category and tag overview plus posts).
I use several categories including sub-categories as well as tags but no custom post types. For example:
- Category “animals” with sub-categories “dogs”, “cats” and a tag “pet-food”
- One post per sub-categorie, each tagged with “pet-food”
- Hosted on www.example.com
For pages I don’t need any customization resulting in www.example.com (/page-A).
For posts the following structure would be ideal:
(1) www.example.com/blog; Showing all three posts
(2) www.example.com/blog/animals; Showing all three posts
(3) www.example.com/blog/animals/dogs; Showing the one post about dogs
(4) www.example.com/blog/animals/dogs/post-about-dogs; Reading the post about dogs
(5) www.example.com/blog/pet-food/; Showing all three posts
I tried so far several approaches. First of all I went to settings -> permalinks and chose the custom permalink option adding
/blog/%category%/%postname%/
while leaving the category and tag base options untouched. Here everything is working besides that “/category” and “/tag” still show up in cases 2,3 and 5.
By adding a “.” into the optional category base the “/category” disappears in case 2 but now the url of case 3 (with and without “/category”) isn’t working. Case 5 is still unfixed.
By adding “/blog” instead of “.” case 2 and 3 will work both without “/category” as intended but now cases 4 and 5 are broken.
I tried several other combinations with also changing the tag base and in none approach every link variation worked. I even tried a couple of times to reset the htaccess file in between different settings with no success.
I already considered Remove category & tag base from WordPress url – without a plugin and dozens of other sites. But unfortunately no configuration worked for me so far. I even tried to strip of the “/category” with the option provided by Yoast SEO (which is already installed and what can be used if needed) but this resulted into also cutting of “/blog”.
Any help is much appreciated – it would be great if you have a solution for this problem!
2
Answers
I finally found a solution to this by myself.
Issues why this procedure is needed:
Issues with this approach:
Simple, install YOAST plugin:
http://prntscr.com/mpcge6