admin管理员组文章数量:1289582
Seriously, why 'with_front' => false
does not work as it should be? It is supposed to remove TAXONOMY BASE NAME and my question is why it does not work?
I just dont want the taxonamy base slug appear in my URL and codex says 'with_front' =>
false should help but it does not. Leaving the slug empty like 'slug'=> ''
generates 404 error.
register_taxonomy("tax_categories", array("products"), array(
"hierarchical" => true,
"label" => "Categories",
"singular_label" => "Category",
"show_ui" => true,
'update_count_callback' => '_update_post_term_count',
"rewrite" => array(
'with_front' => false,
'hierarchical' => true
)
));
This issue supposed to be fixed
Please help to understand that. Thank you.
Seriously, why 'with_front' => false
does not work as it should be? It is supposed to remove TAXONOMY BASE NAME and my question is why it does not work?
I just dont want the taxonamy base slug appear in my URL and codex says 'with_front' =>
false should help but it does not. Leaving the slug empty like 'slug'=> ''
generates 404 error.
register_taxonomy("tax_categories", array("products"), array(
"hierarchical" => true,
"label" => "Categories",
"singular_label" => "Category",
"show_ui" => true,
'update_count_callback' => '_update_post_term_count',
"rewrite" => array(
'with_front' => false,
'hierarchical' => true
)
));
This issue supposed to be fixed http://core.trac.wordpress/ticket/16807
Please help to understand that. Thank you.
Share Improve this question asked Sep 10, 2011 at 20:49 AlexAlex 3052 gold badges4 silver badges13 bronze badges 5 |3 Answers
Reset to default 12To remove the taxonomy base name, you can use:
'rewrite' => ['slug' => '/', 'with_front' => false]
However, this will make your (basic post type) posts go 404, if you have permalinks set to http://example/sample-post/
. It seems you cannot have both custom taxonomy and posts reside in the root. Therefore you would go to Permalinks settings and set Custom structure , e.g. /blog/%postname%/
.
One more note
A side effect is that your CPTs would have this "front", too, e.g. blog/products
. This is where 'with_front' => false
comes to play. It's designed to get you rid of the custom structure start. So in your product type registration, you would have:
register_post_type( 'products', array(
'rewrite' => array(
'slug' => 'products',
'with_front' => false
),
/* ... */
));
All with_front does is toggle whether or not a taxonomy link can have something else in front of it ie extra permalink stuff from the permalinks options page. For example with_front set to true makes this possible:
blah/2011/09/tax/term
with it set to false, all you can do is:
blah/tax/term
Use the code below:
'rewrite' => array(
'slug' => '.',
'with_front' => false
),
Notice that when you rewrite the slug that the default page template is opened, when you go to the taxonomy page.
本文标签: custom post typesTaxonomy Why 39withfront39 gt false DOES NOT WORK
版权声明:本文标题:custom post types - Taxonomy: Why 'with_front' => false DOES NOT WORK? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741407863a2377052.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
with_front
does not remove the taxonomy base name. I assume you want to convert the link format from/tax-categories/banana/
to/banana/
? There was a question about this (it's quite complicated), but I can't find it right now. – Jan Fabry Commented Sep 12, 2011 at 5:59