admin管理员组文章数量:1130349
I have registered a custom taxonomy on "post" named "cat_modules" with this args:
'rewrite' => array(
'hierarchical' => true,
'slug' => '/',
'with_front' => false
)
I used 'hierarchical' => true to have the url structure like 'category/subcateogry' and I used 'slug' => '/' to remove the "cat_modules" from the slug.
These work well on the archive pages but all posts and pages return a 404 error.
If I remove 'slug' => '/' from the args everything work well.
P.S In this web site is installed WPML.
I have registered a custom taxonomy on "post" named "cat_modules" with this args:
'rewrite' => array(
'hierarchical' => true,
'slug' => '/',
'with_front' => false
)
I used 'hierarchical' => true to have the url structure like 'category/subcateogry' and I used 'slug' => '/' to remove the "cat_modules" from the slug.
These work well on the archive pages but all posts and pages return a 404 error.
If I remove 'slug' => '/' from the args everything work well.
P.S In this web site is installed WPML.
Share Improve this question asked Jan 12, 2019 at 13:43 S MadryS Madry 293 bronze badges 2 |1 Answer
Reset to default 0OK, so you've used / as you taxonomy slug. It means that URL for your term is:
http://example/my-sample-taxonomy-term/
And for pages it will be:
http://example/my-sample-page/
As you can see, there is no way to guess, what type of post should WP search for.
WordPress processes the URLs looping through registered Rewrite Rules and matching given URL against regular expression assigned to current rule.
That means that in your case WP will take first rule that will match correctly and try to display that type of object. And because there are two different objects registering rules that are in conflict, then you'll get 404 errors for some of them.
I have registered a custom taxonomy on "post" named "cat_modules" with this args:
'rewrite' => array(
'hierarchical' => true,
'slug' => '/',
'with_front' => false
)
I used 'hierarchical' => true to have the url structure like 'category/subcateogry' and I used 'slug' => '/' to remove the "cat_modules" from the slug.
These work well on the archive pages but all posts and pages return a 404 error.
If I remove 'slug' => '/' from the args everything work well.
P.S In this web site is installed WPML.
I have registered a custom taxonomy on "post" named "cat_modules" with this args:
'rewrite' => array(
'hierarchical' => true,
'slug' => '/',
'with_front' => false
)
I used 'hierarchical' => true to have the url structure like 'category/subcateogry' and I used 'slug' => '/' to remove the "cat_modules" from the slug.
These work well on the archive pages but all posts and pages return a 404 error.
If I remove 'slug' => '/' from the args everything work well.
P.S In this web site is installed WPML.
Share Improve this question asked Jan 12, 2019 at 13:43 S MadryS Madry 293 bronze badges 2-
1
You need something to distinguish it from pages. Otherwise
category/subcateogryjust looks like a page calledsubcategorythat's a sub-page ofcategory. – Jacob Peattie Commented Jan 12, 2019 at 13:45 -
@JacobPeattie Thank you for your answer! I wasn't thinking about it!! now I understand why also the home page works!! Do you know some tricks or best pratices for do that? I forgot to write that I would like also have this URL structure to post like
category\subcategory\post-title. – S Madry Commented Jan 12, 2019 at 14:09
1 Answer
Reset to default 0OK, so you've used / as you taxonomy slug. It means that URL for your term is:
http://example/my-sample-taxonomy-term/
And for pages it will be:
http://example/my-sample-page/
As you can see, there is no way to guess, what type of post should WP search for.
WordPress processes the URLs looping through registered Rewrite Rules and matching given URL against regular expression assigned to current rule.
That means that in your case WP will take first rule that will match correctly and try to display that type of object. And because there are two different objects registering rules that are in conflict, then you'll get 404 errors for some of them.
本文标签: url rewritingPage and Post return 404 with custom taxonomy
版权声明:本文标题:url rewriting - Page and Post return 404 with custom taxonomy 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749018609a2304038.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


category/subcateogryjust looks like a page calledsubcategorythat's a sub-page ofcategory. – Jacob Peattie Commented Jan 12, 2019 at 13:45category\subcategory\post-title. – S Madry Commented Jan 12, 2019 at 14:09