I set permalinks to Custom Structure
with these settings: /postCategory/%category%/%postname%/
.
Also I set up Category Base
to postCategory
.
And this will not work. When I visit post page I am getting page not found.
This produces:
for posts: example.org/postCategory/%category%/%postname% // this will output page not found
for categories: example.org/postCategory/%category% // this works
This doesn’t work only when I use the same word for Category Base
and for prefix in post URL (in this case postCategory
).
So this doesnt work:
Custom Structure: /postCategory/%category%/%postname%/
Category Base: postCategory
and this will work:
Custom Structure: /postCategory/%category%/%postname%/
Category Base: postCategories
So my questions is how I can get this work. To have the same word for Category Base
and in permalinks for post.
These are my permalinks settings:
http://pokit.org/get/img/8a33b710bf98f9e3658edaaf8343cc3b.jpg
EDIT:
I found something similiar here:
But I don’t really understand how to set this function “add_rewrite_rule” for my case:
I have this problem with my custom post type: “product” and custom taxonomy: “product_cat” and want to use “vaporizers” for category base and in permalinks for “product”
So this is my desired setting for permalinks:
http://pokit.org/get/img/bad3b8bea220768b60bb73d49657974a.jpg
And the result for category should be:
www.example.com/vaporizers/product_cat_name
For product:
www.example.com/vaporizers/product_cat_name/product_name
The reason it’s not working is because the category base internal rewrite rule takes precedence in the permalink structure rules (i.e. category rewrites come before post rewrites). So example.org/postCategory/%category% is interpreted as example.org/index.php?category_name=postCategory/%category% and, obviously, WordPress can’t find such category, returning 404 page. It will never search for posts after it fails on the category.
The only work around is to give one more base to a category or post… just like in you “and this will work” example. They have to be different, there’s no other way.