是的,你可以做到。使用函数add\\u menu\\u pagehttp://codex.wordpress.org/Function_Reference/add_menu_page 要添加父级“所有帖子类型”,请使用add\\u submenu\\u pagehttp://codex.wordpress.org/Function_Reference/add_submenu_page 要将页面添加到父页面,请执行以下操作:
add_action( \'admin_menu\', \'my_custom_menu_page\' );
function my_custom_menu_page() {
$slug = \'all-post\';
add_menu_page( \'All post types\', \'All post types\', \'edit_posts\', $slug, \'__return_true\' );
foreach( array( \'post\', \'page\', \'foo\', \'bar\' ) as $post_type ) {
$title = sprintf( \'Post type: %s\', $post_type );
$url = sprintf(\'/edit.php?post_type=%s\', $post_type);
add_submenu_page( $slug, $title, $title, \'edit_posts\', $url );
}
}