自定义帖子类型子菜单

时间:2013-07-23 08:53:31

标签: wordpress admin

有没有办法在管理菜单(插件)上添加子菜单,这个特定菜单是自定义帖子类型?

以下是代码:

// 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"但它似乎无法正常工作。

任何想法都将受到高度赞赏。

0 个答案:

没有答案