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.

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!

share|improve this question
    
This seems to answer the question wordpress.stackexchange.com/questions/19838/… –  Roman Epicnerd Sharf Jan 4 '13 at 23:30
add comment

marked as duplicate by toscho Jan 4 '13 at 23:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

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
}
share|improve this answer
    
Thanks Toscho. Not quite what I was looking for though :) –  Roman Epicnerd Sharf Jan 4 '13 at 23:31
add comment

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