Roger Holga
Roger Holga

Reputation: 105

How can I remove unnecessary menu links from wordpress admin area

I don't need all the menu items and need some custom menu items to be added in the left menu of admin area of Wordpress. Is there any function I can use to do this particularly.

Upvotes: 2

Views: 1523

Answers (2)

CookiesForDevo
CookiesForDevo

Reputation: 721

Add this to the functions.php file:

add_action('admin_menu', 'remove_menus');
function remove_menus () {

    //remove pages
    remove_menu_page('edit.php'); //posts
    remove_menu_page('link-manager.php'); //links
    remove_menu_page('edit-comments.php'); //comments

    //add pages
    add_menu_page('New Page Title', 'New Title in Menu', 'administrator', 'new_page_title', 'f_new_page', $icon_url, 31);
    function f_new_page() { include(get_template_directory_uri() . '/new_page.php';
}

More info on removing: http://codex.wordpress.org/Function_Reference/remove_menu_page

Too add a new menu page, check out the following for an explanation on the variables: http://codex.wordpress.org/Function_Reference/add_menu_page

Upvotes: 0

Samik Chattopadhyay
Samik Chattopadhyay

Reputation: 1860

Place this code in your themes function.php file and customize as you need

/* Remove unnecessary menu items from admin */
function remove_menus () 
{
    global $menu;

    //$restricted = array(
    //  __('Dashboard'), 
    //  __('Posts'), 
    //  __('Media'), 
    //  __('Links'), 
    //  __('Pages'), 
    //  __('Appearance'), 
    //  __('Tools'), 
    //  __('Users'), 
    //  __('Settings'), 
    //  __('Comments'), 
    //  __('Plugins'));

    $restricted = array(__('Links'),__('Media'),__('Appearance'),__('Tools'),__('Posts'));
    end ($menu);
    while (prev($menu)) {
        $value = explode(' ',$menu[key($menu)][0]);
        if(in_array($value[0] != NULL ? $value[0] : "" , $restricted)){unset($menu[key($menu)]);}
    }

    remove_submenu_page('edit.php','edit.php');
    remove_submenu_page('edit.php','post-new.php');
    remove_submenu_page('index.php','update-core.php');
}
add_action('admin_menu', 'remove_menus');

Upvotes: 2

Related Questions