WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking to put widgets in my plug-in settings page like the ones in the WordPress Dashboard.

The action to register the widget is

add_action('wp_dashboard_setup', 'register_widgets' );

I wonder if it's possible to do the same for your own settings pages.

share|improve this question
i think simply register the widget area like we do in the theme and it should work.. – Sisir Nov 14 '11 at 15:37
up vote 2 down vote accepted

You would call:

add_meta_box( $widget_id, $widget_name, $callback, $screen->id, $location, $priority );

Where the screen ID is obtained via:

$screen = get_current_screen();

Then display each location e.g. :

do_meta_boxes( $screen->id, 'column3', '' );

Here's the dashboard function that displays the dashboard:

function wp_dashboard() {
    global $screen_layout_columns;

    $screen = get_current_screen();

    $hide2 = $hide3 = $hide4 = '';
    switch ( $screen_layout_columns ) {
        case 4:
            $width = 'width:24.5%;';
        case 3:
            $width = 'width:32.67%;';
            $hide4 = 'display:none;';
        case 2:
            $width = 'width:49%;';
            $hide3 = $hide4 = 'display:none;';
            $width = 'width:98%;';
            $hide2 = $hide3 = $hide4 = 'display:none;';
<div id="dashboard-widgets" class="metabox-holder">
    echo "\t<div class='postbox-container' style='$width'>\n";
    do_meta_boxes( $screen->id, 'normal', '' );

    echo "\t</div><div class='postbox-container' style='{$hide2}$width'>\n";
    do_meta_boxes( $screen->id, 'side', '' );

    echo "\t</div><div class='postbox-container' style='{$hide3}$width'>\n";
    do_meta_boxes( $screen->id, 'column3', '' );

    echo "\t</div><div class='postbox-container' style='{$hide4}$width'>\n";
    do_meta_boxes( $screen->id, 'column4', '' );

<form style="display:none" method="get" action="">
    wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
    wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );


For further reference, look at wp-admin/index.php and the included dashboard files.

share|improve this answer
Thank you. Almost there, but the toggle button is not working. All the widgets – Omar Abid Nov 15 '11 at 12:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.