Get Order of Meta Box in a Page/Post

I’m using the Posts 2 Posts plugin specifically, but I think this applies to any meta box. I have three Posts 2 Posts metaboxes on the side: “Related Case Studies”, “Related White Papers” and “Related Videos”. I’d like the client to be able to drag these, and have the metabox order correspond to the order they appear on my sidebar. I can do all the backend code to sort properly on the page, I just need to retrieve the value of the metabox order on a per page basis.

Meaning if the client dragged the “Related Videos” metabox above the “Related Case Studies” metabox, I’d be able to grab a value to be aware of that on the page itself and output it exactly like it looks.

Read More

Is this possible?

Thanks.

Related posts

Leave a Reply

1 comment

  1. It’s not that hard: There’s a user Meta entry for that.

    You can not only retrieve the order, but also which ones are hidden (just to get one step further).

    # Meta Box Order
    $meta_box_order = get_user_meta( 
         wp_get_current_user()->ID
        ,sprintf( 'meta-box-order_%s', get_post_type() )
        ,true
    );
    
    # Hidden Meta Box
    $meta_box_hidden = get_user_meta( 
         wp_get_current_user()->ID
        ,sprintf( 'metaboxhidden_%s', get_post_type() )
        ,true
    );