I am trying to create a custom meta box for multiple custom post types in WordPress without creating duplicate code.
Currently I have:
add_meta_box('adv_form_box1', 'Advanced Form', 'adv_form1', 'custom-post-type1', 'side', 'high');
add_meta_box('adv_form_box2', 'Advanced Form', 'adv_form2', 'custom-post-type2', 'side', 'high');
add_meta_box('adv_form_box3', 'Advanced Form', 'adv_form3', 'custom-post-type3', 'side', 'high');
function adv_form1() {
global $post;
$custom = get_post_custom($post->ID);
$filename = $custom['filename'][0]; ?>
<label>Filename:</label> (this field is required)<br/><input name="filename" size="70" value="<?php echo $filename; ?>" />
<?php }
function adv_form2() {
global $post;
$custom = get_post_custom($post->ID);
$filename = $custom['filename'][0]; ?>
<label>Filename:</label> (this field is required)<br/><input name="filename" size="70" value="<?php echo $filename; ?>" />
<?php }
function adv_form3() {
global $post;
$custom = get_post_custom($post->ID);
$filename = $custom['filename'][0]; ?>
<label>Filename:</label> (this field is required)<br/><input name="filename" size="70" value="<?php echo $filename; ?>" />
<?php }
I feel as though I am creating a bunch of extra un-needed code. Is there anyway to set the meta box as "global" to be used in all post-types?