Search code examples
wordpressmenuadmin

Completely customize admin menu without plugin


Basically what I want is to remove most of the admin menu and replace it with my own, without using a plugin. But I'd also like it to stay after a wp update.

Is this a possibility and if so, how? Or is it just a million times easier to make the plugin and be done with it?

EDIT
In /wp-admin there is a menu on the left side. I won't be needing most of the menu and therefor don't want others to see or edit stuff in there(because the only thing that will happen is it will break the site). So I want to remove the unnecesary menu items and add relevant menu items. (It's about Posts, Pages, Media etc)


Solution

  • As others already mentioned you could use the function remove_menu_page, but you still have to put this code somewhere. If you really don't want to create a plugin you could add this code to the functions.php file of your theme.

    In my opinion it's not theme related code, so it would be better to put it in a custom plugin. And it's really easy, here's a video on how to create one within minutes: https://www.youtube.com/watch?v=S9Nhb1KX7vM

    In your case it would look something like:

    <?php
    /*
    Plugin Name:    Custom Admin Menu
    Version:        1.0.0
    Description:    My Custom Admin Menu
    Author:         Peter van der Net
    */
    if (!function_exists('my_custom_admin_menu')):
    
        function my_custom_admin_menu(){
            remove_menu_page('index.php');
            remove_menu_page('plugins.php');
            remove_menu_page('users.php');
            // etcetera..
        }
    
        add_action('admin_menu', 'my_custom_admin_menu');
    
    endif;
    
    /*?>*/
    

    Put this code in a file named custom-admin-menu.php in the folder wp-content/plugins. And then activate the plugin.