
Jeremy Clarke
By: a guest on
Jan 22nd, 2009 | syntax:
PHP | size: 0.70 KB | hits: 680 | expires: Never
function example_add_dashboard_widgets() {
wp_add_dashboard_widget('example_dashboard_widget', 'Example Dashboard Widget', 'example_dashboard_widget_function');
// Globalize the metaboxes array, this holds all the widgets for wp-admin
global $wp_meta_boxes;
// Get the array for your widget from $wp_metaboxes and manually add it to the 'sorted' portion
// This pre-empts the sorting system to make sure you are at the top
// CAVEAT: your widget is no longer sortable. it will always be at the top.
$example_widget = $wp_meta_boxes['dashboard']['normal']['core']['example_dashboard_widget'];
$wp_meta_boxes['dashboard']['normal']['sorted']['example_dashboard_widget'] = $example_widget_backup;
}