Use Metaboxes In Your Theme Or Plugin

Not only the design changed since version 2.5. Also the markup was changed immensely, so there might be changes in the editor area, if you use pluigns, which implements data there.

Here a little workaround, how to keep the design in editor area.

The filter is kept the same but since version 2.5 it isn’t possible to toggle between open and close areas if you don’t change the Plugin accordingly.

add_filter('dbx_post_advanced', 'example_function');

Alternative you can also address the sidebar area. Since WordPress version 2.5 below the advance area. There you can add the additional areas to the standard areas.

add_filter('dbx_post_sidebar', 'tc_post_admin_footer');

For additional areas are hooks like edit_form_advanced and submitpost_box available.
Thereby edit_form_advanced places directly below the editor area, above the advanced options.
The hook submitpost_box gives a new functionality, directly in the save-puplish area.

The structure of the displayed area was the following and complex markup, which was being criticized in the past.

! here is content and your code

Since version 2.5 it looks like the following. It slimmed down and WordPress can also save the status with additional areas; if the user opened the area or closed it, which makes it much easier to work for the user. This happens with help of the appropriate class. WordPress takes care of this and you just need the PHP code at class: <?php echo postbox_classes('pagepassworddiv', 'post'); ?>.

! here is content and your code

Hook add_meta_box

Brand new in WordPress 2.5 is the hook add_meta_box. This makes it easier to create additional boxes. The above html elements can be omitted and just the values have to be delivered.

function add_a_box() {

        'example-div', // id of the
'Example Name', // title 'inside_the_box', // callback function for the content in the box 'post' // for wat is the box: for "post", "page", or "link" page ); } function inside_the_box() { echo " ! here is content and your code "; } // activate the box, when the user active in backend if ( is_admin() ) { add_action('admin_menu', 'add_a_box'); }

Differentiate > WordPress 2.5

With a simple query of this function is a break in different design possible.

if ( function_exists('add_meta_box') ) {
	// > WP 2.5 style
} else {
	// < WP 2.3

Deactivate meta boxen

It’s also possible since version 2.6. You can use the function remove_meta_box() and you can find it in /wp-includes/template.php.
Parameters are $id, $page, $context.

  • $id String for use in the ‘id’ attribute of tags.
  • $page The type of edit page on which to show the box (post, page, link)
  • $context The context within the page where the boxes should show (‘normal’, ‘advanced’)





One response to “Use Metaboxes In Your Theme Or Plugin”

  1. […] easy to integrate and can be controlled like Meta Boxes (explained in detail). The following example shows how you can integrate a widget in a dashboard. WP 2.7 with new […]