1

Possible Duplicate:
Create more Meta Boxes as needed

I am creating a plugin that registers a Custom Post Type. Let's call it "Cars". I am looking to be able to add custom fields(or metaboxes) when I am editing a car, just like what you can do now with a custom field in a post or a CPT but I want to be able to control the HTML/CSS for it(for example I would like it to have 3 input fields). So for example when you are editing a car, there would be a "add new field" button and when you press it a new custom field/metabox(with predefined structure and styling by me) would be added.

Let me know if I am not clear. Thank you!

2

1 Answer 1

1

To add a metabox to a post type car use the proper hook:

add_action( 'add_meta_boxes_car', 'register_car_metabox' );

function register_car_metabox()
{

    add_meta_box(
        'car-data',
        'Car data',
        'car_metabox_callback',
        NULL,
        'normal',
        'default'
    );
}

The content will be created in your callback:

function car_metabox_callback()
{
    # get post meta and print input fields
}
1
  • Thanks Toscho. Not quite what I was looking for though :) Commented Jan 4, 2013 at 23:31

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