Home / Blog / Code Snippets

How to Rearrange and Show/Hide WordPress Admin Sidebar Menu Links Using functions.php

Managing the WordPress backend sidebar can greatly improve the admin experience — especially when working with clients or teams who only need access to specific areas. Instead of relying on plugins, you can take full control of the admin menu directly through your theme’s functions.php file.

In this post, we’ll walk through ready-to-use code snippets that let you hide unwanted menu items, reorder links to match your workflow, and rename labels to suit your project. Whether you’re building a client site or just cleaning up your own dashboard, these snippets are lightweight, plugin-free, and easy to customize.

You can customize the WordPress admin sidebar using hooks in your theme’s functions.php file (or a custom plugin).

Remove / Hide Admin Sidebar Links

Use the admin_menu hook with remove_menu_page() and remove_submenu_page():

<?php 
/**
 * Remove / Hide Admin Sidebar Links
 */

add_action( 'admin_menu', 'hide_admin_sidebar_links', 999 );
function hide_admin_sidebar_links() {
    // Hide top-level menu items
    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
    remove_menu_page( 'woocommerce' );           // WooCommerce (if installed)

    // Hide submenu items
    remove_submenu_page( 'themes.php', 'widgets.php' );       // Widgets
    remove_submenu_page( 'themes.php', 'nav-menus.php' );     // Menus
    remove_submenu_page( 'options-general.php', 'options-reading.php' ); // Reading Settings
}

/**
 * Hide only for non-admins
 */
add_action( 'admin_menu', 'hide_links_for_non_admins', 999 );
function hide_links_for_non_admins() {
    if ( ! current_user_can( 'manage_options' ) ) {
        remove_menu_page( 'plugins.php' );
        remove_menu_page( 'tools.php' );
        remove_menu_page( 'options-general.php' );
    }
}

?>

Reorder / Rearrange Admin Sidebar Links

Use the menu_order filter along with custom_menu_order:

<?php

// Step 1: Enable custom menu order
add_filter( 'custom_menu_order', '__return_true' );

// Step 2: Define your custom order
add_filter( 'menu_order', 'custom_admin_menu_order' );

function custom_admin_menu_order( $menu_order ) {
    return array(
        'index.php',                         // Dashboard (first)
        'edit.php?post_type=page',           // Pages
        'edit.php',                          // Posts
        'upload.php',                        // Media
        'edit-comments.php',                 // Comments
        'separator1',                        // -- Separator --
        'themes.php',                        // Appearance
        'plugins.php',                       // Plugins
        'users.php',                         // Users
        'options-general.php',               // Settings
        'tools.php',                         // Tools
        'separator-last',                    // -- Last Separator --
    );
}

?>

Rename Admin Sidebar Links

<?php
/**
 * Rename Admin Sidebar Links
 **/
add_action( 'admin_menu', 'rename_admin_sidebar_links', 999 );
function rename_admin_sidebar_links() {
    global $menu, $submenu;

    // Rename top-level items
    // $menu[5][0] = 'Articles';    // Rename "Posts" → "Articles"
    // $menu[20][0] = 'Files';      // Rename "Pages" → "Files"

    // Better approach using array search
    foreach ( $menu as $key => $item ) {
        if ( $item[2] === 'edit.php' ) {
            $menu[$key][0] = 'Articles'; // Rename Posts
        }
        if ( $item[2] === 'edit.php?post_type=page' ) {
            $menu[$key][0] = 'Web Pages'; // Rename Pages
        }
    }

    // Rename submenu items
    if ( isset( $submenu['options-general.php'] ) ) {
        foreach ( $submenu['options-general.php'] as $key => $item ) {
            if ( $item[2] === 'options-general.php' ) {
                $submenu['options-general.php'][$key][0] = 'General Config';
            }
        }
    }
}
?>

Common Menu Slugs & Their Default Positions

PositionMenu ItemSlug
2Dashboardindex.php
5Postsedit.php
10Mediaupload.php
15Linkslink-manager.php
20Pagesedit.php?post_type=page
25Commentsedit-comments.php
60Appearancethemes.php
65Pluginsplugins.php
70Usersusers.php
75Toolstools.php
80Settingsoptions-general.php

Need this done on a live site? Exivon Tech takes on projects and audits, led by me.

Dhiren Patel

Principal Full-Stack Engineer · Founder, Exivon Tech

I’ve built and run enterprise web platforms and e-commerce for 13 years, and I built ShieldScope, a free WordPress security scanner.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.