我已向以下用户注册了新的内容类型-
register_post_type(\'news\', array(
\'labels\' => array(
\'name\' => __( \'News\'),
\'singular_name\' => __( \'News\'),
\'add_new\' => _x( \'Add New News\', \'News\'),
\'add_new_item\' => __( \'Add New News\'),
\'edit_item\' => __( \'Edit News\'),
\'new_item\' => __( \'New News\'),
\'view_item\' => __( \'View News Details\'),
\'search_items\' => __(\'Search News\')
),
\'public\' => true,
\'show_ui\' => true,
\'menu_position\' => 6,
\'has_archive\' => false,
\'rewrite\' => array(\'slug\'=>\'news\'),
\'supports\' => array(\'title\', \'editor\' ),
\'taxonomies\' => array(\'category\'),
\'menu_icon\' => plugins_url(\'icons/news.png\', __FILE__),
)
);
这将生成管理菜单项,如下所示--
或
是否可以删除菜单项的重复链接News 来吧hover
主菜单项的。因为,主菜单项News (粗体)将admin带到与子菜单项news相同的页面。简而言之,我只想有两个选项作为子菜单。。这些是添加新新闻和类别。这可能吗??
我试着使用下面的--
add_action(\'admin_menu\', \'remove_news_subitem\');
function remove_news_subitem() {
global $submenu;
unset($submenu[\'edit.php?post_type=news\']);
}
但这会删除所有子菜单。
我相信没有这样的钩子来做这件事。我能想象的唯一选择是编辑核心文件。但是我strongly 不想这样做。
当菜单项在domReady上呈现时,可以使用jQuery实现这一点。但这很难看。可以从php本身完成吗??
最合适的回答,由SO网友:dipali 整理而成
刚刚添加\'all_items\' => __( \'\' ),
在标签数组中。
用以下代码替换您的代码
register_post_type(\'news\', array(
\'labels\' => array(
\'name\' => __( \'News\'),
\'singular_name\' => __( \'News\'),
\'add_new\' => _x( \'Add New News\', \'News\'),
\'add_new_item\' => __( \'Add New News\'),
\'edit_item\' => __( \'Edit News\'),
\'new_item\' => __( \'New News\'),
\'view_item\' => __( \'View News Details\'),
\'all_items\' => __( \'\' ),
\'search_items\' => __(\'Search News\')
),
\'public\' => true,
\'show_ui\' => true,
\'menu_position\' => 6,
\'has_archive\' => false,
\'rewrite\' => array(\'slug\'=>\'news\'),
\'supports\' => array(\'title\', \'editor\' ),
\'taxonomies\' => array(\'category\'),
\'menu_icon\' => plugins_url(\'icons/news.png\', __FILE__),
)
);