RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts</strong | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.69% (5.89%*) • Home Loan Fixed: 5.39% (6.67%*) • Fixed: 5.39% (6.67%*) • Variable: 5.69% (5.89%*) • Investment IO: 5.69% (6.52%*) • Investment PI: 5.49% (5.98%*)

Customize the WordPress Admin Panel Meta Boxes (and Change the Default News Feed)

The snippets on this page were migrated from the now retired Internoetics website. If you find any errors or omissions, please let us know (it was written before WP made their own panel modifications).

■ ■ ■

If you design a website for a client you'll invariably want to white-label WordPress in different ways to better reflect their (or your) own brand. Depending upon the specific needs of your customer, you might consider altering the appearance of the WordPress administration dashboard to better suit their needs. The dashboard displays an activity log, quick draft area, the "at a glance" information, and WordPress news - all by default (and much of it irrelevant). It's likely you'll want to customize these areas - particularly the news feed that you can alter for your own website. If you're writing plugins there's also a good chance you may want to add a meta box on the dashboard to support your app.

This article will show you how to add simple meta boxes to the dashboard, and how to remove the default news feed and replace it with your own.

Removing Meta Boxes from the Admin Panel

The WordPress Codex page details how to remove meta boxes from a particular post edit screen for a particular post type (in our example, dashboard). If you're deploying WordPress to a client you may want to remove specific boxes that are largely irrelevant (the WP news RSS feed with forced WPtavern news is one such example). To use the following function, uncomment the meta boxes you choose to remove.

1
<?php 
2
/*
3
 Customize the WordPress Admin Panel Meta Boxes (and Change the Default News Feed)
4
 http://www.beliefmedia.com/code/wp-snippets/customize-wordpress-admin-panel
5
*/
6
 
7
function remove_dashboard_widgets () {
8
  // remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' ); // Quick Press widget
9
  // remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' ); // Recent Drafts
10
  // remove_meta_box( 'dashboard_primary', 'dashboard', 'side' ); // WordPress.com Blog
11
  // remove_meta_box( 'dashboard_secondary', 'dashboard', 'side' ); // Other WordPress News
12
  // remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' ); // Incoming Links
13
  // remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' ); // Plugins
14
  // remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' ); // Right Now
15
  // remove_meta_box( 'dashboard_activity', 'dashboard', 'normal' ); // Dashboard Activity
16
}
17
add_action('wp_dashboard_setup', 'remove_dashboard_widgets');

On a network site you should use 'dashboard-network' as the second parameter rather than 'dashboard'.

I use once used the plugin wp-filebase and it includes an unwanted meta box in my admin panel. Because 'admin_menu' is fired early, it renders the box after wp_dashboard_setup, so we use the do_meta_boxes action instead. As per the WP Codex, this is handy if you want to limit meta boxes by user role (the do_meta_boxes hook is called in the wp-admin/edit-form-advanced.php file after all the meta boxes have been added to the page).

1
<?php 
2
/*
3
 Customize the WordPress Admin Panel Meta Boxes (and Change the Default News Feed)
4
 http://www.beliefmedia.com/code/wp-snippets/customize-wordpress-admin-panel
5
*/
6
 
7
function beliefmedia_remove_plugin_metaboxes() {
8
  remove_meta_box('wpfb-add-file-widget', 'dashboard', 'normal');
9
}
10
add_action('do_meta_boxes', 'beliefmedia_remove_plugin_metaboxes');

The remove_meta_box function can be used to remove any meta boxes from any page type. As mentioned, the boxes can be removed depending upon the user role , meaning you can discriminately render different pages to authors depending upon their privileges.

Add a Simple Meta Box to the Administration Panel

To display a simple meta box in the admin panel we make use of wp_add_dashboard_widget and wp dashboard setup . The function is as follows:

1
<?php 
2
/*
3
 Customize the WordPress Admin Panel Meta Boxes (and Change the Default News Feed)
4
 http://www.beliefmedia.com/code/wp-snippets/customize-wordpress-admin-panel
5
*/
6
 
7
function beliefmedia_custom_dashboard_widget_output() {
8
  echo '<div class="rss-widget">';
9
  echo 'Hello, I am a widget.';
10
  echo '</div>';
11
}
12
 
13
function beliefmedia_custom_dashboard_widget() {
14
  wp_add_dashboard_widget( 'dashboard_custom_feed', 'BeliefMedia' , 'beliefmedia_custom_dashboard_widget_output');
15
}
16
add_action('wp_dashboard_setup', 'beliefmedia_custom_dashboard_widget');

The beliefmedia_custom_dashboard_widget_output is used to print any content. You would normally be calling the content as an option or returning genuine dynamic content.

To display the meta box in a particular location rather than just rendering underneath others (which is the default behaviour), you should use the add_meta_box function instead. In company with our beliefmedia_custom_dashboard_widget_output() (callback) function that we used to generate the returned HTML, you can use the following rather than the beliefmedia_custom_dashboard_widget function and wp_dashboard_setup action.

1
<?php 
2
/*
3
 Customize the WordPress Admin Panel Meta Boxes (and Change the Default News Feed)
4
 http://www.beliefmedia.com/code/wp-snippets/customize-wordpress-admin-panel
5
*/
6
 
7
function beliefmedia_dashboard_widgets_output() {
8
  add_meta_box( 'id',
9
    'BeliefMedia Message',
10
    'beliefmedia_custom_dashboard_widget_output',
11
    'dashboard',
12
    'side',
13
    'high'
14
  );
15
}
16
add_action('wp_dashboard_setup', 'beliefmedia_dashboard_widgets_output');

The function parameters are listed here .

Replacing the default WordPress Dashboard Feed

By default WordPress includes a feed that includes WordPress and other news. If you've built a website for a client it's fair to say that they'll be more interested in your (RSS) news feed than the techie-type WP news displayed by default.

Adding one or more feeds is done in the manner described below. We've used wp_widget_rss_output to generate the feed (replacing the text in the functions above).

1
<?php 
2
/*
3
 Customize the WordPress Admin Panel Meta Boxes (and Change the Default News Feed)
4
 http://www.beliefmedia.com/code/wp-snippets/customize-wordpress-admin-panel
5
*/
6
 
7
function beliefmedia_dashboard_rss_feed() {
8
  echo '<div class="rss-widget">';
9
  $return .= wp_widget_rss_output(array('url' => 'http://www.beliefmedia.com/feed/', 'title' => 'BeliefMedia', 'items' => 3, 'show_summary' => 1, 'show_author' => 0, 'show_date' => 1));
10
  // $return .= wp_widget_rss_output(array('url' => 'http://www.flight.org/feed', 'title' => 'Flight', 'items' => 2, 'show_summary' => 1, 'show_author' => 0, 'show_date' => 1 ));
11
  echo '</div>';
12
}
13
 
14
function beliefmedia_dashboard_rss_widget() {
15
  global $wp_meta_boxes;
16
  wp_add_dashboard_widget( 'beliefmedia_dashboard_rss_feed', 'BeliefMedia' , 'beliefmedia_dashboard_rss_feed' );
17
}
18
add_action('wp_dashboard_setup', 'beliefmedia_dashboard_rss_widget');

The widget will now show your own feed rather than WordPress'. Screenshot below.

Customize the WordPress Admin Panel Meta Boxes (and Change the Default News Feed)

Considerations

  • We have a shortcode scheduled that will merge multiple RSS feeds. As part of that article we provide code that will render multiple feeds in a meta box as we've done above.
  • In another scheduled article we use the dashboard meta box to include a form that'll update core elements of your website.
  • This post is quite old. Please report errors.

■ ■ ■

 
Download our complimentary 650-page guide on marketing for mortgage brokers. We'll show you exactly how we generate billions in volume for our clients.
Finance Guide, Cropped Top and Bottom
  Timezone: 1 · [ CHANGE ]

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment