[wp-hackers] Drag and drop panels in plugin's page

Andrew Nacin wp at andrewnacin.com
Thu Jun 16 15:10:39 UTC 2011


On Thu, Jun 16, 2011 at 10:34 AM, due chiacchiere <info at duechiacchiere.it>wrote:

> Andrew,
>
> according to the Codex, those functions only work on some admin pages:
>
> Theadd_meta_box()function was introduced inVersion 2.5 <
> http://codex.wordpress.org/Version_2.5>. It allows plugin developers to
> add sections to the Write Post, Write Page, and Write Link editing pages.
>
> http://codex.wordpress.org/Function_Reference/add_meta_box
>
> I want to create "movable" boxes in a new custom page generated by my
> plugin. Is there something I'm missing here?
>

Yes. In that add_meta_box() takes a screen ID. By default, only certain
screens are supported -- the screens that call do_meta_boxes().

You can then call do_meta_boxes() the way core would, to generate meta
boxes.

Example:

<div class="postbox-container">
<?php
// Parameters: Screen identifier, placement on the screen
(normal/side/column3, etc.), an object that gets passed to the meta box.
do_meta_boxes( $screen->id, 'normal', $post );
?>
</div>

And:

add_meta_box( ... ) where the $page parameter is your $screen->id.


More information about the wp-hackers mailing list