我创建了如下cpt:
register_post_type( \'mission\', array(
\'labels\' => array( ... ),
\'supports\' => array( \'title\', \'editor\', \'comments\', \'revisions\', \'trackbacks\', \'author\', \'post-formats\' ),
\'taxonomies\' => array( \'mission_category\', \'mission_client\', \'mission_location\', \'mission_status\'),
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 5,
\'menu_icon\' => \'dashicons-star-filled\',
\'can_export\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'post\',
)
);
以及上述cpt的自定义分类法:
register_taxonomy( \'mission_category\', array( \'mission\' ), array(
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_tagcloud\' => true,
\'show_admin_column\' => true,
\'hierarchical\' => true,
\'capabilities\' => array(
\'manage_terms\' => \'manage_categories\',
\'edit_terms\' => \'manage_categories\',
\'delete_terms\' => \'manage_categories\',
\'assign_terms\' => \'edit_posts\',
),
\'rewrite\' => array(
\'slug\' => \'mission/category\',
\'with_front\' => false,
\'hierarchical\' => true,
\'ep_mask\' => EP_NONE
),
)
);
我已经创建了两个
mission_categories
命名为:“工程”和“经济”。我希望在以下端点找到存档页:
/mission/category/engineering
和
/mission/category/economy
我还创建了两个与上述类别同名的页面。我希望在以下位置找到这些页面:/engineering
和/economy
奇怪的是,当我创建了与我的mission_categories
, 当我试图查看归档文件时,会被重定向到该页面。也就是说,如果我手动输入此端点/mission/category/economy
我最终在/economy
. 值得一提的是,admin中mission\\u类别页面的“查看链接”是正确的,但我在单击该页面时仍会被重定向到该页面。
只有当我有一个与类别同名的页面时,才会发生这种情况。。。例如,如果我删除经济页面,则/mission/category/economy
以正确的url结束。