Customizing the WordPress Admin Area



Introduction

If you’re using WordPress just forself, then everything that comes with WordPress preconfigured is probably fine, but what about when you have setup a client site with WordPress, which your client will be using as a content management system? Well, assuming your clients are like everyone else’s clients, they’re probably not familiar with WordPress, which means that the simpler you can make the interface, the better their experience will be.

In this tutorial, I will be demonstrating to you how to customize several different sections of the WordPress admin area, including Dashboard widgets, left menu items, post/page meta boxes, and list columns. By the end of this, your WP admin area will be much better suited to inexperienced clients, making both your life and their’s easier.

Removing Dashboard Widgets

Probably one of the number one annoyances with the default WordPress admin area is the large number of widgets on the dashboard. Sure you can remove them by configuring the “Screen Options”, but this only applies to your personal user profile. What if you want to get rid of some of them for ALL users, especially your new-to-WordPress clients?

It is actually pretty simple. By putting a little bit of code into your functions.php file, we can remove any one of the widgets we wish.

The basic code looks like this:

// remove dashboard widgets
function example_remove_dashboard_widgets() {
// load the metaboxes array as a global variable
>global $wp_meta_boxes;

// we need to manually unset each widget
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
}

// Hoook into the 'wp_dashboard_setup' action to remove the widgets defined above
add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets' );

The code above will remove the Quick Press widget from the dashboard. To remove others, we just need to unset them as well.

Here’s a list of all the different widget names:

Main column
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']

Side Column
$wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']
$wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']
$wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']
$wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']

If we wanted to remove all of them, our function would look like this:

// remove dashboard widgets
function example_remove_dashboard_widgets() {
// load the metaboxes array as a global variable
>global $wp_meta_boxes;

// side widgets
unset($wp_meta_boxes['dashboard']['side']['core']['recent_drafts']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);

//normal widgets
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
}

// Hoook into the 'wp_dashboard_setup' action to remove the widgets defined above
add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets' );

Removing WordPress Menu Items

Another way that we can make WordPress easier for our clients to use, is by removing unnecessary links from the main WP admin menu.

Let’s say, for example, that you have setup a site that uses posts and pages, but not links. There’s really no reason for the links menu to be available to your client if they’re never going to use it.

We can remove the links menu with this function:

// function to remove the Links menu item
function remove_menus()
{
// setup the global menu variable
>global $menu;
// this is an array of the menu item names we wish to remove
$restricted = array( __('Links'));
end ($menu);

while (prev($menu))
{
$value = explode(' ',$menu[key($menu)][0]);

if(in_array($value[0] != NULL?$value[0]:"" , $restricted))
{
unset($menu[key($menu)]);
}
}
}
// hook into the action that creates the menu
add_action('admin_menu', 'remove_menus');

The $restricted variable is an array that contains a list of all the menu items we’d like to remove from the WordPress menu. So, to remove more than just the links, all we have to do is add the others like this:

// function to remove the Links menu item
function remove_menus()
{
// setup the global menu variable
>global $menu;
// this is an array of the menu item names we wish to remove
$restricted = array( __('Links'),__('Tools'),__('Settings'),__('Comments'));
end ($menu);

while (prev($menu))
{
$value = explode(' ',$menu[key($menu)][0]);

if(in_array($value[0] != NULL?$value[0]:"" , $restricted))
{
unset($menu[key($menu)]);
}
}
}
// hook into the action that creates the menu
add_action('admin_menu', 'remove_menus');

We have now removed Links, Tools, Settings, and Comments from the WordPress menu.

Removing Meta Boxes from Editor Screen

Another main area of confusion for non-WordPress-familiar clients, is the custom fields meta box on post / page editor screens. And let’s face it, does it really make any sense at all, unless you are experienced with WordPress? Nope. So, unless you’re actively using them for some function or other, there’s no reason not to remove them from a site you’re delivering to a client.

Our function to remove the custom fields looks like this:

function remove_extra_meta_boxes() {
remove_meta_box( 'postcustom' , 'post' , 'normal' ); // remove custom fields from posts
remove_meta_box( 'postcustom' , 'page' , 'normal' ); // remove custom fields from pages
}
add_action( 'admin_menu' , 'remove_extra_meta_boxes' );

We can extend this function to get rid of other unnecessary meta boxes as well. This next function will remove just about every meta box on the post/page editor screen, stripping them to their bare minimums (sometimes best):

function remove_extra_meta_boxes() {
remove_meta_box( 'postcustom' , 'post' , 'normal' ); // custom fields for posts
remove_meta_box( 'postcustom' , 'page' , 'normal' ); // custom fields for pages
remove_meta_box( 'postexcerpt' , 'post' , 'normal' ); // post excerpts
remove_meta_box( 'postexcerpt' , 'page' , 'normal' ); // page excerpts
remove_meta_box( 'commentsdiv' , 'post' , 'normal' ); // recent comments for posts
remove_meta_box( 'commentsdiv' , 'page' , 'normal' ); // recent comments for pages
remove_meta_box( 'tagsdiv-post_tag' , 'post' , 'side' ); // post tags
remove_meta_box( 'tagsdiv-post_tag' , 'page' , 'side' ); // page tags
remove_meta_box( 'trackbacksdiv' , 'post' , 'normal' ); // post trackbacks
remove_meta_box( 'trackbacksdiv' , 'page' , 'normal' ); // page trackbacks
remove_meta_box( 'commentstatusdiv' , 'post' , 'normal' ); // allow comments for posts
remove_meta_box( 'commentstatusdiv' , 'page' , 'normal' ); // allow comments for pages
remove_meta_box('slugdiv','post','normal'); // post slug
remove_meta_box('slugdiv','page','normal'); // page slug
remove_meta_box('pageparentdiv','page','side'); // Page Parent
}
add_action( 'admin_menu' , 'remove_extra_meta_boxes' );

Removing / Editing Columns from Post Browser

When browsing through the lists of posts / pages in your WordPress dashboard, sometimes it can be necessary to remove certain columns from the layout. For example, perhaps you have disabled tags for posts, and therefor have no reason to display a column for “Tags”. If this is the case, then getting rid of it is not too difficult.

This function represents the default columns. If you paste it in your function.php, you will not see any difference in your columns.

function remove_post_columns($posts_columns) {
// Delete an existing column
$posts_columns = array(
"cb" => "",
"title" => "Title",
"author" => "Author",
"categories" => "Categories",
"tags" => "Tags",
"date" => "Date",
"comments" => '
<div class="vers"><img src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" alt="Comments" /></div>
',
);

return $posts_columns;
}
add_filter('manage_posts_columns', 'remove_post_columns');

But now, the following function will get rid of the “Tags” column:

function remove_post_columns($posts_columns) {
// Delete an existing column
$posts_columns = array(
"cb" => "",
"title" => "Title",
"author" => "Author",
"categories" => "Categories",
"date" => "Date",
"comments" => '
<div class="vers"><img src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" alt="Comments" /></div>
',
);

return $posts_columns;
}
add_filter('manage_posts_columns', 'remove_post_columns');

By simply removing the “tags” => “Tags” line, we have removed the column entirely. We can also reorder the layout of the columns however we wish, simply by changing the order of the lines in the $post_columns array.

function remove_post_columns($posts_columns) {
// Delete an existing column
$posts_columns = array(
"cb" => "",
"title" => "Title",
"date" => "Date",
"tags" => "Tags",
"categories" => "Categories",
"author" => "Author",
"comments" => '
<div class="vers"><img src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" alt="Comments" /></div>
',
);

return $posts_columns;
}
add_filter('manage_posts_columns', 'remove_post_columns');

This will give us a column order of: (checkbox), Title, Date, Tags, Categories, Author, Comments.

Further Reading – Resources

This post should help you in many of the customizations you may need to do to your WordPress admin area, but if you’d like to go a few steps further, here are some excellent links to get you there:

If you are looking for fast success in testking 650-297 exams then join today to explore complete citrix certification resources and pass network+ certification on first try. A person can chose pass4sure & testking E20-335 for his easiness.



Comments
  1. WOW this is going to save me from a ton of phone calls I would get from clients, THANKS!

  2. О! Sebagai Newbie, saya selalu mencari online untuk artikel yang bisa membantu saya. Terima kasih Wow! Terima kasih! Saya selalu ingin menulis dalam sesuatu situs saya seperti itu. Dapatkah saya mengambil bagian dari posting Anda ke blog saya?
    ———-
    О! As a Newbie, I am always looking online for articles that can help me. Wow thanks! Thank you! I always wanted to write in my site something like that. Can I take part of your post to my blog?

  3. whre is DEMO boy..?

  4. Is there a way to define the number of columns on the dashboard, then specify which widgets you want in each column?

    I’m unable to find anything on that right now and it would be really helpful if there was a way to do it. I want all my users dashboards to look exactly how I want them.

    • I’m not aware of an easy way, though I’m sure you could explore into the core WordPress files and maybe find a way. But that’s not generally a good idea.

      Each widget is classified as either “normal” or “side”, so if you could find a way to reclassify them, you might be on the right track.

  5. Thank you for developing this website. The stories here are worth reading many times over in order to refresh us time and time again to do good and positive things and inspire or influence others to do the same.

  6. For some reason, the Recent Drafts widget is the only one that doesn’t disappear from the dashboard. Anybody know why?

  7. Thank you so much!

  8. Hi Pippin. Great solution you have here. I also make websites for clients using WordPress. In my search for a nice solution (clean dashboard) I found a CMS plugin which lets you add your own content (html-page or rss feed) to the dashboard. I wrote a litle step by step tutorial about it on my blog. Maybe this is also useful to you.

  9. Really interesting and helpful post! … Two quick questions though…
    ? How do you make customisations for say, “Authors” and not Administrators.
    ? Can these functions be reworked to add menu features for some accounts perhaps.
    thanks