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 wondering if it's possible to get status and position of metaboxes added to a dashboard-like page.

The main page of my plugin has several metaboxes laying in a two-columns page and a "table of content" box on top (with internal links, like a wikipedia page). However, since you can order/hide/reveal a metabox, the TOC box should be updated accordingly via an ajax method.

Is it possible to trigger a method like that, passing all parameters i need to accomplish the ordering (position and status of all metaboxes)?

tnx in advance,


share|improve this question
up vote 1 down vote accepted

You can hook into the sortstop event of the sortable metaboxes, and read the current state:

jQuery( function( $ ) {
    $( '.meta-box-sortables' ).bind( 'sortstop', function( event, ui ) {
        var sortData = {};
        $('.meta-box-sortables').each( function() {
            sortData[this.id.split('-')[0]] = $(this).sortable( 'toArray' );
        } );
        console.log( sortData );
    } );
} );

You can also hook into the events that hide or reveal metaboxes, but this requires some more work on your side, since WordPress does not provide nice events for this. See the postbox.js script for more details.

There are other answers on this site that deal with the Ajax part.

share|improve this answer

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.