How To Hide Items From The Administration Menu

Here we learn about how to hide items from the administration menu.

1. remove_menu_page

This function is used to remove a top-level admin menu.

Syntax:

<?php remove_menu_page( string $menu_slug ); ?>

Parameters:

$menu_slug – (string)(Required) Pass slug of the menu.

Custom code copied and paste into your child theme’s functions.php file.

Here is an example hide the entire “Settings” menu.

<?php
add_action( 'admin_menu', 'myblog_hide_settings' );
function myblog_hide_settings() {
    remove_menu_page( 'options-general.php' );
}
?>

OUTPUT:

2. remove_submenu_page

This function is used for removing an admin submenu.

Syntax:

<?php remove_submenu_page( string $menu_slug, string $submenu_slug ); ?>

Parameters:

  • $menu_slug – (string)(Required) Pass slug for the parent menu.
  • $submenu_slug – (string)(Required) Pass slug of the submenu.

Here is an example to hide a sub-menu item from the menu.

you can use the below code copied and paste into your child theme’s functions.php file.

<?php
add_action( 'admin_menu', 'myblog_hide_settings_submenu' );
function myblog_hide_settings_submenu() {
    remove_submenu_page( 'options-general.php', 'options-permalink.php' );
}
?>

OUTPUT:

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe

Select Categories