我有一个名为product的自定义帖子类型和一个名为product_types的产品的自定义分类,它是分层的,因此我有子类别。
我希望永久链接显示为http://mysite.com/product_type/sub_category/postname
我尝试了很多插件和我在网上找到的东西,到目前为止没有任何工作。
谢谢。
答案 0 :(得分:1)
首先我会仔细检查创建自定义帖子类型的功能, 在该函数中应该有一个名为:rewrite
的元素即:
register_post_type( 'products',
'menu_position' => 25, // below pages
'public' => true,
'show_ui' => true,
'rewrite' => array( 'slug' => 'product' ) <-- this is what you need!
);
同样检查register_taxonomy函数!
即:
register_taxonomy(
'team',array('product_types'),
array(
'public' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'query_var' => true,
'hierarchical' => true, <-- this is needed!
'rewrite' => true <-- this is what you need!
));
唯一需要检查的是:
您的永久链接结构设置为/%postname%/ 您可能需要重置为默认值,保存, 然后重新设置为/%postname%/并保存,
希望有所帮助:)
玛蒂