Add dashbard widget to right column

I saw on the blog how to add a custom dashboard widget:
https://premium.wpmudev.org/blog/adding-custom-widgets-to-the-wordpress-admin-dashboard/

I used the code and and it adds it to the left column, how could I modify this to display on the right column instead?

Do I need to add 'side' in there somewhere? Here is the code I used:

<?php
function register_my_dashboard_widget() {
global $wp_meta_boxes;
wp_add_dashboard_widget(
'my_dashboard_widget',
'Custom Help Widget',
'my_dashboard_widget_display'
);
$dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
$my_widget = array( 'my_dashboard_widget' => $dashboard['my_dashboard_widget'] );
unset( $dashboard['my_dashboard_widget'] );
$sorted_dashboard = array_merge( $my_widget, $dashboard );
$wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
}
add_action( 'wp_dashboard_setup', 'register_my_dashboard_widget' );
function my_dashboard_widget_display() {
?>

<p>
We can put what ever we need in here.
</p>

<?php
}
?>

Thanks!!

  • George

    Yeah you can drag them around but when a new user goes to the dashboard for the first time, they are all on the left. I removed some of the default widgets and added 5 of my own so now I have like 7 widgets that appear opened and its a really long column on the left with a blank space on right.

    I know there is a way, its just beyond me.....
    Saw this in the docs:

    Advanced: Adding Widgets onto the side
    The function doesn't allow you to choose where you want your widget to go and will automatically add it to the "core" which is the left side. However you are able to get it on the right side very easily.
    
    You can use the add_meta_box() function instead of wp_add_dashboard_widget. Simply specify 'dashboard' in place of the $post_type.
  • calvinrogercanas

    Hey there @George,

    Hope you're well! :slight_smile:

    Try using this instead of wp_add_dashboard_widget()

    function register_my_dashboard_widget() {
    
    add_meta_box(
    'my_dashboard_widget',
    'Custom Help Widget',
    'my_dashboard_widget_display',
    'dashboard', 'side', 'high' );
    
    }
    
    add_action( 'wp_dashboard_setup', 'register_my_dashboard_widget' );

    Let me know if it helps! :slight_smile:

    Best Regards,
    Calvin

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.