I have static front-page and separate page /news/ as the Posts page. I would like to have the single-post URLs like this:

www.example.com/news/categoryname/subcategory/postname/

and for the category archives:

www.example.com/news/categoryname/

What I’ve tried already:

  • If I add news as my category base and /news/%category%/%postname%/ as the custom permalink structure, I get the desired URLs but also 404 error for single posts (both with news/ in URL and without it). All other pages (e.g. category archives, pages etc.) are accessible.

  • If I leave category-base empty and permalinks as /news/%category%/%postname%/, there are no 404 errors, but category URLs additionally contain the default category slug, like so: www.example.com/news/category/categoryname/

  • If I use plugins to remove the default category base or just set category base to . it’s removed together with the news part

  • If I set permalinks as /%category%/%postname%/ and add only the category base news, there are also no 404 errors, but links to posts don’t start with news: www.example.com/categoryname/subcategory/postname/

There are some similar unanswered questions: Posts not showing with custom categorybase and subcategories and wordpress permalinks tweeks

4 s
4

You only need to add “/.” after category base:

Category base: news/. (/. is required as it prevents 404s for post).

This worked perfectly for me 🙂

EDIT: This field will strip trailing or leading slashes unless you include the “.”

Leave a Reply

Your email address will not be published. Required fields are marked *