Question

I am trying to add a menu box to Pages > Pages or Pages > Add New, basically whenever they access a page, be it to edit an existing page or add a new one, I would like to add a menu box under the Page Attributes box on the right, or anywhere on those pages that I can add a input form into to work in conjunction with the plugin I am trying to build.

I am very very new to wordpress plugin development, so please forgive my ignorance on the subject, any learning materials or good resources on the subject would also be greatly appreciated!

Thanx in advance!

Was it helpful?

Solution

add_action('add_meta_boxes', 'add_testbox');

function add_testbox() {
    add_meta_box( 'testmetabox', 'Test Meta Box', 'testmetabox_content', 'post', 'side', 'low');
}

function testmetabox_content() {
    echo "hi";
}

You can drag and drop the box into the spot you want it to display.

Make sure you always wrap the add_meta_box() function in another function, then hook that in like I showed. If you call add_meta_box() outside the function, you'll get a fatal error.

This example is for WordPress 3.0 and above. As the WordPress Codex shows, the 'add_meta_boxes' hook I used was added in WP 3.0. If you're using an older version of WordPress, (which you shouldn't be), use 'admin_init' instead of 'add_meta_boxes'.

OTHER TIPS

actually quite simple - you can use add_meta_box ( see http://codex.wordpress.org/Function_Reference/add_meta_box ) to add as many different meta boxes as you like to your post type (page in your case).

This allows you to render custom html in your box, just remember to use the save_post action to intercept your post data.

Updated. after your comment i read the question again and i saw that i was wrong with my answer and your title was miss leading.

what you are looking for is call Meta Box. there are about 100 of questions around here that show just how to add one to your edit screen but if you are just starting out i would recommend trying the tut here http://www.deluxeblogtips.com/2010/04/how-to-create-meta-box-wordpress-post.html

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top