Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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!

share|improve this question

migrated from stackoverflow.com Jan 24 '11 at 22:13

This question came from our site for professional and enthusiast programmers.

    
exact duplicate: wordpress.stackexchange.com/questions/7648/… –  Michal Mau Jan 25 '11 at 5:18
    
possible duplicate of How to add meta boxes to the 'Add new post' screen? –  Jan Fabry Jan 25 '11 at 8:38

3 Answers 3

up vote 1 down vote accepted
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'.

share|improve this answer
    
Thank you, that is perfect, I just had to change the type from post to page and that did the trick! –  Odyss3us Jan 24 '11 at 20:27

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

share|improve this answer
    
Thank you for the reply, although that seems to be adding in a sub menu for the left hand admin sidebar, where as I am trying to add a menu inside of the post.php page underneath the Page Attributes box on the right. Any idea on how I can add that in? Or am I missing something? –  Odyss3us Jan 24 '11 at 20:21
    
No you are just fine ,i miss read your question hold on ill update the answer –  Bainternet Jan 25 '11 at 4:52

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.

share|improve this answer
    
Thank you for the help! That did the trick, and I'll have a look at save_post. I wish I could choose more than one answer though. :/ –  Odyss3us Jan 24 '11 at 20:29
    
@user2632 Don't let this prevent you from actually choosing one (as accepted) :) –  Michal Mau Jan 25 '11 at 5:21
    
Haha no ofcourse not. :) –  Odyss3us Jan 25 '11 at 8:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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