[Tutorials] Hide menu admin page in wordpress without plugin

hide-menu-admin-page-in-wordpress

[Tutorials] Hide menu admin page in wordpress without plugin

You are the admin of the website, when handing over the website to other members, you want to hide the items related to editing the code for fear of causing errors. Or when you install a lot of plugins on your website, those plugins will create a few menus in the admin section, which can make your website untidy. So if you intend to hide those menus, you can follow the instructions below.

Custom hide and show Menus admin page in WordPress

First you need to open the functions.php file in the theme folder you are using
then add this code to the opened file:

function flatsomeaz_admin_menus() {
remove_menu_page( 'index.php' ); // Menu Dashboard
remove_menu_page( 'edit.php' ); // Menu Post
remove_menu_page( 'upload.php' ); // Menu Media
remove_menu_page( 'edit.php?post_type=page' ); // Menu Page
remove_menu_page( 'edit-comments.php' ); // Menu Comment
remove_menu_page( 'themes.php' ); // Menu Themes
remove_menu_page( 'plugins.php' ); // Menu Plugins
remove_menu_page( 'users.php' ); // Menu Members
remove_menu_page( 'tools.php' ); // Menu Tool
remove_menu_page( 'options-general.php' ); // Menu setting
}
add_action( 'admin_menu', 'flatsomeaz_admin_menus' );

This code will help you to hide all the default WordPress menus.

If you just wanted to hide the Plugin menu, the code would be:

function flatsomeaz_admin_menus() {
remove_menu_page( 'plugins.php' ); // Menu Plugins
}
add_action( 'admin_menu', 'flatsomeaz_admin_menus' );

– Hide the Menu of the generated Plugins:
You may have noticed that when entering the plugin menu, it will often look like the image below:

hide-menu-admin-page-in-wordpress
hide-menu-admin-page-in-wordpress

On the browser bar you note the red square, this is the name for you to use to hide the plugin menu.

function flatsomeaz_admin_menus() {
remove_menu_page( 'wpcf7' ); // Delete Menu Contact form 7
remove_menu_page( 'bhittani_plugin_kksr_settings' ); // Delete Menu kk Star Ratings
remove_menu_page( 'wpseo_dashboard' ); // Delete Menu Seo By Yoast
}
add_action( 'admin_menu', 'flatsomeaz_admin_menus' );

Tested and works perfectly!

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *