如何在WordPress网站中隐藏管理菜单项?
打开您主题的functions.php文件 并添加以下代码,或者,如果使用的是特定于站点的插件,则还可以添加以下代码。
function fwm_hide_item_menu_dashboard(){
if( !(current_user_can(‘administrator’)) ) {
remove_menu_page( ‘index.php’ ); //Dashboard
remove_menu_page( ‘edit.php’ ); //Posts
remove_menu_page( ‘upload.php’ ); //Media
remove_menu_page( ‘edit.php?post_type=page’ ); //Pages
remove_menu_page( ‘edit-comments.php’ ); //Comments
remove_menu_page( ‘themes.php’ ); //Appearance
remove_menu_page( ‘plugins.php’ ); //Plugins
remove_menu_page( ‘users.php’ ); //Users
remove_menu_page( ‘tools.php’ ); //Tools
remove_menu_page( ‘options-general.php’ ); //Settings
}
}
add_action( ‘admin_menu’, ‘fwm_hide_item_menu_dashboard’ );