gpt4 book ai didi

php - add_submenu_page() 出现在子菜单的顶部而不是底部

转载 作者:行者123 更新时间:2023-12-03 23:56:55 25 4
gpt4 key购买 nike

我正在使用 add_submenu_page将子级菜单添加到帖子类型。

问题是子级菜单“批次”出现在帖子类型名称“离线类(class)”的顶部,但我希望它出现在底部

enter image description here

// Register Custom Post Type
function register_offline_course() {

$argscourse = array(
'label' => __( 'Offline Course', 'Offline Course' ),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'revisions', ),
'taxonomies' => array( 'offline_course_cat' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => false,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type( 'course_offline', $argscourse );

$argsbatch = array(
'label' => __( 'Batch', 'Batch' ),
'supports' => array( 'title','revisions', ),
'taxonomies' => array( 'offline_course_cat' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => false,
'menu_position' => 5,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => false,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type( 'course_batches', $argsbatch );

add_submenu_page( 'edit.php?post_type=course_offline', 'Batches', 'Batches',
'manage_options', 'edit.php?post_type=course_batches', NULL );
}
add_action( 'init', 'register_offline_course', 0 );

最佳答案

请在自定义帖子类型函数之外创建 add_submenu_page 函数并调用 admin_menu 操作 Hook 来创建子菜单,然后它就会起作用。

// Register Custom Post Type
function register_offline_course() {

$argscourse = array(
'label' => __( 'Offline Course', 'Offline Course' ),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'revisions', ),
'taxonomies' => array( 'offline_course_cat' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => false,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type( 'course_offline', $argscourse );

$argsbatch = array(
'label' => __( 'Batch', 'Batch' ),
'supports' => array( 'title','revisions', ),
'taxonomies' => array( 'offline_course_cat' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => false,
'menu_position' => 5,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => false,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type( 'course_batches', $argsbatch );

}
add_action( 'init', 'register_offline_course', 0 );

function sep1_menuexample_create_menu() {
//create a submenu under Settings
add_submenu_page( 'edit.php?post_type=course_offline', 'Batches', 'Batches',
'manage_options', 'edit.php?post_type=course_batches',NULL );}

add_action( 'admin_menu', 'sep1_menuexample_create_menu' );

关于php - add_submenu_page() 出现在子菜单的顶部而不是底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43977301/

25 4 0