在我的插件中,我有一个自定义的贴子类型,上面有一段“成衣”,我还有一个自定义的分类法,叫做“季节”。
奇怪的是,这个url和查询一起工作:
http://dev.catwalkyourself.com/ready-to-wear/?seasons=autumn-winter-2012-2013-en
但与custom permalink相同的版本没有:
http://dev.catwalkyourself.com/ready-to-wear/seasons/autumn-winter-2012-2013-en
它抛出404错误。您可以尝试自己粘贴链接。
以下是我的相关插件代码:
此处是注册自定义帖子类型的位置
$post\\U types=数组();
$post_types[\'rtw\'] = $args = array(
\'labels\' => array(
\'name\' => __(\'RTW Collections\'),
\'singular_name\' => __(\'Ready to Wear Collection\'),
\'add_new\' => __(\'Add new RTW collection\'),
\'add_new_item\' => __(\'Add a new show to the RTW collection\'),
\'edit_item\' => __(\'Edit Collection\'),
\'view_item\' => __(\'View Collection\'),
\'search_items\' => __(\'Search Ready to Wear Collections\'),
\'not_found\' => __(\'No RTW Collections found\'),
\'not_found_in_trash\' => __(\'No RTW Collections found in trash\')
),
\'query_var\' => \'rtw_collections\',
\'supports\' => array(\'title\', \'editor\', \'thumbnail\', \'author\', \'comments\'),
\'has_archive\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'taxonomies\' => array(\'seasons\',\'city\'),
\'rewrite\' => array(
\'slug\' => \'ready-to-wear\',
\'with_front\' => false
),
\'public\' => true,
\'menu_position\' => 6
);
下面是分类法的配置位置:
$分类法=数组();
$taxonomies[\'seasons\'] = array(
\'query_var\' => \'seasons\',
\'rewrite\' => array(
\'slug\' => \'seasons\',
\'with_front\' => false
),
\'single_value\' => true,
\'required\' => true,
\'labels\' => array(
\'name\' => __(\'Seasons\'),
\'singular_name\' => __(\'Season\'),
\'edit_item\' => __(\'Edit Season\'),
\'update_item\' => __(\'Update Season\'),
\'add_or_remove_items\' => __(\'Add or remove seasons\'),
\'new_item_name\' => __(\'Add new Season\'),
\'all_items\' => __(\'All Seasons\'),
\'search_items\' => __(\'Search Seasons\'),
\'popular_items\' => __(\'Popular Seasons\'),
\'separate_items_with_commas\' => __(\'Separate Items with commas\'),
\'choose_from_most_used\' => __(\'Choose from most used Seasons\')
)
);
这是呼叫
register_taxonomy
:
foreach ($taxonomies as $taxonomy => $arr) {
register_taxonomy($taxonomy, null, $arr);
}
我尝试过:
反复刷新永久链接设置“with\\u front”true和false反复将刷新重写操作添加到我的函数中。不幸的是,这些都不起作用。请帮帮我。