有没有办法在管理菜单(插件)上添加子菜单,这个特定的菜单是自定义帖子类型?
这是代码:
// The Main Menu
add_action( 'admin_menu', 'create_main_menu' );
function create_main_menu(){
add_menu_page(
'Menu Title',
'Menu Name',
'manage_options',
'menuslughere',
'display_custom_page'
);
}
function display_custom_page(){
include 'sample_page.php';
}
// The Submenu
add_action( 'init', 'create_my_custom_post_type' );
function create_my_custom_post_type() {
register_post_type( 'post_type_name',
array(
'labels' => array(
'name' => 'Sample',
'menu_name' => 'Sample',
'singular_name' => 'Sample',
'add_new' => 'Sample',
'add_new_item' => 'Sample',
'edit' => 'Edit',
'edit_item' => 'Edit Sample',
'new_item' => 'New Sample',
'view' => 'View',
'view_item' => 'View Sample',
'search_items' => 'Search Sample',
'not_found' => 'No Sample found',
'not_found_in_trash' => 'No Sample found in Trash',
'parent' => 'sample_parent'
),
'show_ui' => true,
'show_in_menu' => 'admin.php?page=menuslughere',
'public' => true,
'supports' => array( 'title', 'editor' ),
'taxonomies' => array( '' ),
'has_archive' => true
)
);
}
如果您要检查代码,帖子类型部分的注册...我已经为 show_in_menu 提供了“admin.php?page=menuslughere”,但它似乎不起作用。
任何想法将不胜感激。