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 using the following code in functions.php for adding a custom meta box.

The custom post type is themes. I want to add more post types, how can I?

add_meta_box( 
    'my-meta-box-id', 
    'Demo & Download', 
    'cd_meta_box_cb', 
    'themes', 
    'normal', 
    'high' 
);
share|improve this question
    
Do you want to add more Custom Post Types or add the same metabox to other post types? –  brasofilo Dec 11 '12 at 2:43
    
I want to add same meta box to other post types too. –  Ahmad Dec 11 '12 at 2:45
add comment

1 Answer

up vote 3 down vote accepted

Whenever in doubt about a WordPress function, consult the Codex.
http://codex.wordpress.org/Function_Reference/add_meta_box

There, you'll see that you need to add one meta box to each post type.

add_action( 'add_meta_boxes', 'myplugin_add_custom_box' );

function myplugin_add_custom_box() {
    add_meta_box( 
        'myplugin_sectionid',
        __( 'My Post Section Title', 'myplugin_textdomain' ),
        'myplugin_inner_custom_box',
        'post' 
    );
    add_meta_box(
        'myplugin_sectionid',
        __( 'My Post Section Title', 'myplugin_textdomain' ), 
        'myplugin_inner_custom_box',
        'page'
    );
}
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.