我想为permalink添加一个自定义slug,用于CPT和分类。像这样:
http://mydomain.com/my-custom-slug/post-slug
http://mydomain.com/my-custom-slug/product_category
以下是我的CPT和分类代码:
$args = array(
\'query_var\' => \'product\',
\'capability_type\' => \'post\',
\'rewrite\' => array(\'slug\' => \'my-custom-slug\'),
);
register_post_type( \'product\', $args );
上述CPT
product
输出所需permalink,
http://mydomain.com/my-custom-slug/post-slug
但它给出了错误404。
分类法也会发生同样的事情:
register_taxonomy(\'product_category\', array(\'product\'), array(
\'hierarchical\' => true,
\'rewrite\' => array(\'slug\' => \'my-custom-slug\', \'hierarchical\' => false, \'with_front\' => false)
));
请告诉我如何修复此问题。谢谢你的帮助。