How to Remove Posts, Dashboard Widgets and other Elements of the WordPress Administrative Backend
I use WordPress as a Content Management System, ie. CMS, for nearly every one of my clients. The control and flexibility it provides means they save cash updating their sites, and I save time (and therefore, more cash for the client) building the websites thanks to built in features like search and the flexibility of plugins. That said, WordPress comes packed with a lot of features that most of my clients don’t use, or some just don’t need on a per client basis.
This little tutorial will walk you through a few easy steps on how to hide or disable various features in the backend.
Everything we’ll discuss here today goes into your functions.php file.
Removing Dashboard Widgets
Most of my clients could care less about updates from the WordPress developer’s blog. Many of my sites are too complicated to utilize features like Quick Press (as I often have lots of custom fields that are required to get a post looking and functioning correctly). Removing Dashboard widgets is a pretty easy task. Just add the following code to your functions.php file, somewhere between the tags. I’ve made some notes in the code below, just delete any lines for widgets that you wan’t to keep.
function remove_dashboard_widgets() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']); // Removes QuickPress
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']); // Incoming Links
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']); // Removes Right Now
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']); // Removes Plugins
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']); // Removes Recent Drafts
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']); // Removes Recent Comments
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']); // Removes the WordPress Developer Blog
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); // Removes the WordPress Blog Updates
}
add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );
Hiding Navigation Elements
Not all of my clients want to manage a blog, or therefore comments, and even fewer want to manage a list of links outside of the Page functionality. Here I’ll show you how to hide any primary sidebar navigation item. Note that this does not actually remove the functionality, but simply hides the navigation element via CSS.
add_action( 'admin_head', 'cn_admin_customize' );
function cn_admin_customize() { ?>
<style type="text/css" media="screen">
#welcome-panel, #menu-posts, #menu-media, #menu-links, #menu-pages, #menu-comments, #menu-appearance, #menu-plugins, #menu-users, #menu-tools, #menu-settings {display:none;}
</style>
<?php }
What that does is injects some CSS into your admin pages’ header, and tells it to hide various elements. The #welcome-panel
can be excluded, that hides the initial Welcome message that is shown on the Dashboard when a user logs in. If you don’t hide this, well, it has links pointing to many of the other areas of the site we’re trying to hide, making it kind of pointless to hide them.
You can extend this practice to just about anything else you can get the ID or narrow down the element enough via CSS to hide.
Enjoy!