Categories: Snippets

Remove Admin Menus

add_action( 'admin_menu', 'remove_admin_menus' );
add_action( 'admin_menu', 'remove_admin_submenus' );

//Remove top level admin menus
function remove_admin_menus() {
    remove_menu_page( 'edit-comments.php' );
    remove_menu_page( 'link-manager.php' );
    remove_menu_page( 'tools.php' );
    remove_menu_page( 'plugins.php' );
    remove_menu_page( 'users.php' );
    remove_menu_page( 'options-general.php' );
    remove_menu_page( 'upload.php' );
    remove_menu_page( 'edit.php' );
    remove_menu_page( 'edit.php?post_type=page' );
    remove_menu_page( 'themes.php' );
}


//Remove sub level admin menus
function remove_admin_submenus() {
    remove_submenu_page( 'themes.php', 'theme-editor.php' );
    remove_submenu_page( 'themes.php', 'themes.php' );
    remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=post_tag' );
    remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=category' );
    remove_submenu_page( 'edit.php', 'post-new.php' );
    remove_submenu_page( 'themes.php', 'nav-menus.php' );
    remove_submenu_page( 'themes.php', 'widgets.php' );
    remove_submenu_page( 'themes.php', 'theme-editor.php' );
    remove_submenu_page( 'plugins.php', 'plugin-editor.php' );
    remove_submenu_page( 'plugins.php', 'plugin-install.php' );
    remove_submenu_page( 'users.php', 'users.php' );
    remove_submenu_page( 'users.php', 'user-new.php' );
    remove_submenu_page( 'upload.php', 'media-new.php' );
    remove_submenu_page( 'options-general.php', 'options-writing.php' );
    remove_submenu_page( 'options-general.php', 'options-discussion.php' );
    remove_submenu_page( 'options-general.php', 'options-reading.php' );
    remove_submenu_page( 'options-general.php', 'options-discussion.php' );
    remove_submenu_page( 'options-general.php', 'options-media.php' );
    remove_submenu_page( 'options-general.php', 'options-privacy.php' );
    remove_submenu_page( 'options-general.php', 'options-permalinks.php' );
    remove_submenu_page( 'index.php', 'update-core.php' );
}

 

Recent Posts

Adding or Including custom post type to default WordPress loop

Adding or Including custom post type to default WordPress loop by altering the 'pre_get_posts' function.…

5 years ago

How to Limit or Disable WordPress Post Revisions

Limit the number of posts revisions that WordPress stores in the database. edit wp-config.php file…

5 years ago

Multisite – List Recent Posts Across an Entire Network

In Multisite, List Recent Posts Across an Entire Network by using custom query or WP_Query…

5 years ago

Disable update notification for individual plugins / All

code for the plugin file itself:- [crayon-66388a32db04f804918091/] I like to put this in the actual…

5 years ago

How to change the WordPress permalink structure to remove dates from the URLs

Switching the permalink structure from /year/month/post-slug to just /post-slug is easy by going to Settings…

6 years ago

Limit character in content and title in wordpress

[crayon-66388a32db43a088450478/] or with readmore [crayon-66388a32db443269050866/]  

6 years ago