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 just tried the first time to extend a custom post type admin-UI-edit-page with some "meta" boxes (if this is the right word).

register_post_type('post_type', array('register_meta_box_cb' => 'additional_input_field') );

function additional_input_field() {
global $post;
$custom = get_post_custom( $post->ID );
$length = $custom["post_type-length"][0];

return print '<label>Length:</label><input name="post_type-length" value="'.$length.'" />'; }

So far i haven't seen any documentation or example about how to use this. A look in the core showed me that it should be equal to:

add_action( 'add_meta_boxes'.$post_type, 'additional_input_field', 10, 1 );

The appropriate hook can be found in (core) /root/wp-admin/edit-form-advanced.php line 163. The call for add_action in (core) /root/wp-includes/post.php line 877. The only problem is that it doesn't seem to work as expected. The field get's loaded in front (visually: on top) of everything else. If i try to hook it directly to 'add_meta_boxes'.$post_type, i get nothing...

Simplified examples in this text to show what i mean. Typos may be there but doesn't matter. The callback fn is taken from some sample code over here.

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

I love answering my own questions: Wrap the function add_additional_input_field() in a new function that contains this and call it in the register_meta_box_cb argument.

And yes: This is the solution.

share|improve this answer
add comment

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.