(临时?)我选择的解决方案如下:
使用show_in_menu
的参数register_post_type
使用javascript在页面加载后显示自定义标题,使用以下帮助函数解决子菜单页面顺序(自动将自定义帖子类型置于顶部,这不是我的意图):。。。// Sort the children of a given toplevel menu item
// Keep original order intact as much as possible, while
// enforcing the [before => after] rules given by $force_order
function help_sort_submenu_items($toplevel_slug, $force_order) {
global $submenu;
$done = array();
$hold = array();
$newmenu = array();
foreach ($submenu[$toplevel_slug] as $i => $item) {
$force_after = array_search($item[2], $force_order);
if ($force_after !== false && empty($done[$force_after])) {
$hold[$item[2]] = $item;
} else {
$newmenu []= $item;
$done[$item[2]] = true;
$just_added_id = $item[2];
while ($just_added_id = $force_order[$just_added_id]) {
$next = $hold[$just_added_id];
$newmenu []= $next;
$done[$just_added_id] = true;
}
}
}
$submenu[$toplevel_slug] = $newmenu;
}
用法如下:help_sort_submenu_items(\'my_plugin_toplevel_menu_item_slug\', array(
\'submenu_page_with_this_slug_comes_before\' => \'submenu_page_with_this_slug\',
\'another\' => \'rule\'
));