WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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) ~/wp-admin/edit-form-advanced.php line #163. The call for add_action in (core) ~/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
up vote 5 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
Would you also use the add_meta_boxes hook? I'm a little confused could you add an example please? – Howdy_McGee Jul 31 '14 at 20:49
@Howdy_McGee Just saw your reply (a little late). Are you still confused? – kaiser Dec 21 '14 at 14:07

Your Answer


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.