我知道我可以添加重写规则来实现这一点,但我希望影响WordPress生成的链接(例如,当我将自定义分类术语放入菜单时)
我今天花了一整天的时间来解决这个问题,所以目前我认为这是不可能的。
谁能证明我错了吗?
下面是我用来注册帖子类型和分类的代码:
$labels = array(
\'name\' => \'Event categories\',
\'singular_name\' => \'Event category\',
\'search_items\' => \'Search Event categories\',
\'all_items\' => \'All Event categories\',
\'parent_item\' => \'Parent category\',
\'parent_item_colon\' => \'Parent Event category:\',
\'edit_item\' => \'Edit Event category\',
\'update_item\' => \'Update Event category\',
\'add_new_item\' => \'Add New Event category\',
\'new_item_name\' => \'New Event category Name\',
\'menu_name\' => \'Event categories\'
);
$args = array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'query_var\' => true,
\'slug\' => array( \'slug\' => \'events-category\' )
// \'events/category\' doesn\'t work
);
register_taxonomy( \'events-category\', null, $args );
$labels = array(
\'name\' => \'Events\',
\'singular_name\' => \'Event\',
\'menu_name\' => \'Events\',
\'parent_item_colon\' => \'Parent Event:\',
\'all_items\' => \'All Events\',
\'view_item\' => \'View Event\',
\'add_new_item\' => \'Add New Event\',
\'add_new\' => \'Add New\',
\'edit_item\' => \'Edit Event\',
\'update_item\' => \'Update Event\',
\'search_items\' => \'Search Event\',
\'not_found\' => \'Not found\',
\'not_found_in_trash\' => \'Not found in Trash\',
);
$args = array(
\'label\' => \'event\',
\'description\' => \'An Event\',
\'labels\' => $labels,
\'supports\' => array( \'title\', \'editor\', \'excerpt\', \'thumbnail\', \'revisions\', \'page-attributes\' ),
\'taxonomies\' => array( \'events-category\' ),
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 5,
\'can_export\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'page\',
);
register_post_type( \'event\', $args );