Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

Is this possible?

Thanks.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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
);
share|improve this answer
    
Works perfectly. Thanks! –  LOLapalooza Oct 23 '12 at 15:37

Your Answer

 
discard

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.