【发布时间】:2016-08-26 22:36:34
【问题描述】:
我有以下菜单和子菜单的结构。如何添加新菜单并在其中放置带有子选项的自定义帖子类型菜单。我做的不对。好心的建议。
下面是代码
function wpdocs_register_my_custom_menu_page(){
add_menu_page(
__( 'Custom Menu Title', 'textdomain' ),
'SANHA Menu',
'manage_options',
'custompage',
'my_custom_menu_page',
plugins_url( 'myplugin/images/small-flag.png' ),
6
);
}
add_action( 'admin_menu', 'wpdocs_register_my_custom_menu_page' );
add_action( 'init', 'salman' );
function salman(){
register_post_type( 'salu',
array(
'labels' => array(
'name' => __( 'Salmans' ),
'singular_name' => __( 'salman' )
),
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-media-text',
'hierarchical' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_menu' => 'edit.php',
'query_var' => true,
'rewrite' => array('slug' => 'restaurants',),
'supports'=> array( 'title', 'editor', 'excerpt', 'author', 'thumbnail',),
)
);
}
【问题讨论】: