The Goal

I would like to format my permalinks as follows:

  • for posts: somePrefix/%category%/%postname%
  • for categories: somePrefix/%category%

Where somePrefix is the same in both cases.

I know that there is no big upside to this - it just seems "clean" to me :) . And it comes in handy if you want to manually edit the URL.

What I Tried

No Category Base

One approach is to define the posts' permalinks as /%category%/%postname%/ and use a plugin to get rid of the category base. Unfortunately those plugins seem to be buggy and are discouraged to use (e.g. by Yoast SEO Plugin).

Same Category Base

No problem, I thought, let's just use the category base in the permalinks as so: category_base/%category%/%postname%. This produces:

  • for posts: example.org/category_base/%category%/%postname%
  • for categories: example.org/category_base/%category%

This works for the categories but now links to posts produce 404s.

Now What?

So is there a way to achieve this? A setting, a plugin or perhaps even hacking WordPress a little to properly process the links which created by Same Category Base?

  • Your issue is that your desired structures are too close. The second approach looks like it should work in principle, but because the prefix is same posts are getting confused with category names. Not sure how to best untangle it, especially in a robust way. – Rarst Jun 9 '14 at 18:32

I may be missing some vital detail in the question but here's what I did to make this work.

Settings -> Permalinks

Set the permalinks to...

/somePrefix/%category%/%postname%/

This will give you the following permalinks...

Blog Page     - domain.com/somePrefix
Category Page - domain.com/somePrefix/currCategory/
Single Page   - domain.com/somePrefix/currCategory/singlePost/

If you install some kind of plugin like Yoast you'll be able to pick a "Primary" category for your permalink which is nice.

  • When doing this, I also get the /somePrefix/ base on the authors archive. How to solve this issue? – Sam Feb 16 '17 at 1:59

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.