WordPress

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:

Rahul Prajapat

I’m Rahul Prajapat. I’m a WordPress developer and Author at TheCodeHubs. I have good skill of Html, CSS, JQuery, SQL, Web API, PSD to HTML/PSD to WordPress, WordPress Theme/Plugin Customization, create or modify short code, customize visual composer short code or integrate new short code with visual composer, can create custom metabox for any post type in WordPress admin.

Share
Published by
Rahul Prajapat

Recent Posts

Testing hk

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Operation

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

TETS NEW

test

3 years ago