如何在wordpress中更改分类URL
跟随
this question 和
this one但却无法得到预期的结果。
The default is:
example.com/project_category/%category%/
What I want is:
example.com/stainless-steel-products/%category%/
我已经更改了项目档案的slug,以便
example.com/stainless-steel-products/
是项目档案。
下面是用于实现该目标的代码。
// Change peralinks projects
function custom_project_slug () {
return array(
\'feeds\' => true,
\'slug\' => \'stainless-steel-products\',
\'with_front\' => false,
);
}
add_filter( \'et_project_posttype_rewrite_args\', \'custom_project_slug\' );
?>
如何更改项目类别的slug,使其成为项目归档的子级?提前感谢您的帮助!
最合适的回答,由SO网友:jasmines 整理而成
add_filter( \'register_taxonomy_args\', \'change_taxonomies_slug\', 10, 2 );
function change_taxonomies_slug( $args, $taxonomy ) {
if ( \'project_category\' === $taxonomy ) {
$args[\'rewrite\'][\'slug\'] = \'stainless-steel-products\';
}
return $args;
}