0

I've looked through many similar questions, but haven't yet been able to find a solution to my particular problem. It seems fairly straight-forward, but I can't seem to find the correct combination of settings to fit my desired structure. I would like my (standard) posts to have a URL of mysite.com/blog/postname. I then have a couple of category archives that I would like to have a URL of mysite.com/blog/categoryname.

In the Permalinks menu, setting a custom structure of /blog/%postname%/ generates the correct URLs for the single post view, but sets a URL of mysite.com/blog/category/categoryname for the archive. Using a plugin like Yoast to remove /category/ from the URL generates the correct link to the category page in the WP-provided navigation (mysite.com/blog/categoryname), but seems to ultimately redirect to mysite.com/categoryname.

I've also tried different combinations like setting blog in both the custom structure and the category base. This generates the correct links in WP-nav and to the category archives, but ultimately results in a 404 for the single posts.

It seems like I'm overlooking something simple, so I would appreciate it if anyone could point me in the correct direction. Thanks!

1 Answer 1

0

The issue with your desired structure (and that categories without base are common request but commonly unreliable) is ambiguity.

Each rewrite rule is like a tiny program, explaining WP how to turn URL into query variables. It is very important that WP can reliably distinguish which of the rules should handle particular URL.

In plain words the usual case would be following rules:

  1. blog, followed by post name.
  2. blog, followed by taxonomy name, followed by term name.

With your configuration rules become the following:

  1. blog, followed by post name.
  2. blog, followed by term name.

Notice how this is much less clear case. How is WP supposed to guess if that is post or term at the end? How is it supposed to guess which taxonomy that term belongs to?

In a nutshell such structure is inherently unreliable and is not supported by WP core. You might beat it into submission eventually, but I would recommend just to stick with robust and unambiguous rewrite rules.

1
  • I really appreciate taking the time to provide this information. It makes perfect sense, and at least gives me some ammo to push back a bit.
    – Dan W
    May 31, 2016 at 20:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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