Adding boxes to WordPress 2.5+ Write Post panel
I have noticed few inconsistencies in the WordPress 2.6.1 code regarding the methods to add content boxes to the WordPress Write Post panel.
The old way included using
add_action('dbx_post_advanced', 'myplugin_old_custom_box' ); add_action('dbx_post_sidebar', 'myplugin_old_custom_box' );
which would add a box to the Advanced section and Sidebar.
However since version 2.5 dbx_post_sidebar actually adds a box to the end of Advanced section not the sidebar. In return dbx_post_advanced ads code to the beginning of the section.
Proper way to add admin boxes in 2.5+
WordPress 2.5 introduces another function to add the box. It is :
add_meta_box( 'myplugin_sectionid', __( 'My Post Section Title', 'myplugin_textdomain' ), 'myplugin_inner_custom_box', 'post', 'advanced', 'default' );
Parameters are id, title, callback function for drawing, type ('post', 'page' or 'link' panels), section ('normal', 'advanced') and priority ('high', 'core', 'default', 'low').
In order to add a box to the sidebar you need to use :
add_action('submitpost_box', 'myplugin_sidebar');
The best would be if add_meta_box function would be changed in the following version to also render sidebar boxes. But until then that's how we need to do it.
About this entry
You’re currently reading “Adding boxes to WordPress 2.5+ Write Post panel,” an entry on Vladimir Prelovac site, published: Monday, August 25th, 2008
-
Check more articles like this:
- Best practice for adding JavaScript code to WordPress plugins
- Improving security in Wordpress plugins using Nonces
- Wordpress plugin recommendations
-
Write a comment.
-
Get my newsletter, RSS feed or twitter.
Hi! My name is Vladimir Prelovac. I am a computer engineer by profession and an adventurer by state of mind.
1 comment
Jump to main menu | Jump to comment form | Toggle comments