Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从wordpress中删除“添加新项目”,但允许编辑_Wordpress_Function - Fatal编程技术网

从wordpress中删除“添加新项目”,但允许编辑

从wordpress中删除“添加新项目”,但允许编辑,wordpress,function,Wordpress,Function,我有这段代码,可以从我开发的站点上的非管理员用户删除页面 function remove_menu_items() { if (!current_user_can('manage_options')){ remove_menu_page( 'index.php' ); remove_menu_page( 'edit-comments.php' ); remove_menu_page( 'edit.php' ); remove_menu_page( 'edit.ph

我有这段代码,可以从我开发的站点上的非管理员用户删除页面

function remove_menu_items() {
if (!current_user_can('manage_options')){
    remove_menu_page( 'index.php' );
    remove_menu_page( 'edit-comments.php' );
    remove_menu_page( 'edit.php' );
    remove_menu_page( 'edit.php?post_type=page' );
    remove_menu_page( 'edit.php?post_type=hp_slides' );
    remove_menu_page( 'post-new.php?post_type=foodswaps' );
    }
}
add_action( 'admin_menu', 'adjust_the_wp_menu', 999 );

但是底部删除项不起作用,帖子类型正确,但子菜单项仍然保留。有人能看出我做错了什么吗?

几周前我就有这个问题

因此,您正试图删除子菜单项,因此需要使用如下内容:

function remove_menu_items() {
    if ( ! current_user_can( 'manage_options' ) ) {
        // remove new post button from the food swaps custom post type if not admin
        $page = remove_submenu_page( 'edit.php?post_type=foodswaps', 'post-new.php?post_type=foodswaps' );
    }
}
add_action( 'admin_menu', 'remove_menu_items' );

这真是一种享受,谢谢!我从未想到它是一个子菜单,而不是一个菜单页面项:-/