使用参数\'show_in_menu\'
在函数中register_post_type()
将此CPT添加到菜单。也可以在现有或创建的菜单项中用作子菜单。现在,以一个示例将此作为子菜单添加到现有自定义帖子类型中。
// This custom post type will be added as a submenu to the \'Portfolio\' menu
$args = array(
\'labels\' => array(
\'all_items\' => \'Locations\',
\'menu_name\' => \'Locations\',
\'singular_name\' => \'Location\',
\'edit_item\' => \'Edit Location\',
\'new_item\' => \'New Location\',
\'view_item\' => \'View Location\',
\'items_archive\' => \'Location Archive\',
\'search_items\' => \'Search Locations\',
\'not_found\' => \'No locations found.\',
\'not_found_in_trash\' => \'No locations found in trash.\'
),
\'supports\' => array( \'title\', \'editor\', \'revisions\' ),
\'show_in_menu\' => \'edit.php?post_type=portfolio\',
\'public\' => TRUE
);
register_post_type( \'location\', $args );