自定义帖子类型和自定义分类的WordPress永久链接
问题描述:
我有一个称为product的自定义帖子类型和一个名为product_types的产品的自定义分类,这是分层的,所以我有它的子分类。自定义帖子类型和自定义分类的WordPress永久链接
我想永久链接显示为http://mysite.com/product_type/sub_category/postname
我尝试了很多插件和东西,我发现网上,没有到目前为止的工作。
谢谢。
答
首先,我会仔细检查这是该函数中创建自定义文章类型, 功能应该有所谓的一个元素:改写
即:
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%/和保存,
希望帮助:)
马蒂
另请参见:http://wordpress.stackexchange.com/search?q=Primalink+custom+post+type+custom+taxonomy – fuxia 2012-04-24 14:14:53
是的,我做了搜索,没有解决方案为我工作。 – aghoshx 2012-04-25 19:05:55
_Doesn't work_不是一个有用的描述。启用调试模式并记下确切的错误。 – fuxia 2012-04-25 19:07:37