WordPress: Sortable Metabox Fields Not Saving Position

Normally it should be enough to simply enqueue the postsbox script on a page where you want to have sortable meta boxes.

Simply do the following:

add_action( 'admin_enqueue_scripts', 'wpse112022_postbox_enqueue' );
function wpse112022_postbox_enqueue( $hook_suffix )
{
    // uncomment the next line to see what the $hook_suffix of your desired page is
    # var_dump( $hook_suffix );
    if ( 'hook_suffix of desired page' !== $hook_suffix )
        return;

    wp_enqueue_script( 'postbox' );
    // If the last line didn't enqueue the script, then uncomment the following instead:
    /*
    $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
    wp_enqueue_script(
        'postbox',
        "/wp-admin/js/postbox{$suffix}.js",
        array( 'jquery-ui-sortable' ),
        false
        true
    );
    */
}

Leave a Comment

error code: 523