2

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.

2

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
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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