I made a similar site and created each team as a custom post type. For the meta fields I did:
$report_custom_meta_fields = array(
array(
'label' => 'Match Date',
'desc' => 'Choose match date',
'id' => $prefix.'date',
'type' => 'date'
),
array(
'label' => 'Select Home Team',
'desc' => 'Select home team from list',
'id' => $prefix.'home-select',
'type' => 'post_list',
'post_type' => array('team_page')
),
array(
'label' => 'Select Home Score',
'desc' => 'Select home score',
'id' => $prefix . 'homescore',
'type' => 'text'
),
array(
'label' => 'Select Away Team',
'desc' => 'Select away team from list',
'id' => $prefix.'away-select',
'type' => 'post_list',
'post_type' => array('team_page')
),
array(
'label' => 'Select Away Score',
'desc' => 'Select away team score',
'id' => $prefix . 'awayscore',
'type' => 'text'
)
);
And then the callback:
function show_report_custom_meta_box() {
global $report_custom_meta_fields, $post;
// Use nonce for verification
$nonce = wp_create_nonce(basename(__FILE__));
echo '<input type="hidden" name="report_custom_meta_box_nonce" value="'. $nonce .'" />';
// Begin the field table and loop
echo '<table class="fixture">';
foreach ($report_custom_meta_fields as $field) {
// get value of this field if it exists for this post
$meta = get_post_meta($post->ID, $field['id'], true);
// begin a table row with
echo '<tr>
<th><label for="'.$field['id'].'">'.$field['label'].'</label></th>
<td>';
switch($field['type']) {
// text
case 'text':
echo '<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="2" /><br /><span class="description">'.$field['desc'].'</span>';
break;
// radio
case 'radio':
echo '<ul class="meta_box_items">';
foreach ( $field['options'] as $option )
echo '<li><input type="radio" name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '-' . $option['value'] . '" value="' . $option['value'] . '" ' . checked( $meta, $option['value'], false ) . ' />
<label for="' . esc_attr( $field['id'] ) . '-' . $option['value'] . '">' . $option['label'] . '</label></li>';
echo '</ul>' . '<span class="description">'.$field['desc'].'</span>';
break;
// select
case 'select':
echo '<select name="'.$field['id'].'" id="'.$field['id'].'">';
foreach ($field['options'] as $option) {
echo '<option', $meta == $option['value'] ? ' selected="selected"' : '', ' value="'.$option['value'].'">'.$option['label'].'</option>';
}
echo '</select><br /><span class="description">'.$field['desc'].'</span>';
break;
echo '<span class="description">'.$field['desc'].'</span>';
// date
case 'date':
echo '<input type="text" class="datepicker" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="30" />
<br /><span class="description">'.$field['desc'].'</span>';
break;
// post_list
case 'post_list':
$items = get_posts( array (
'post_type' => $field['post_type'],
'posts_per_page' => -1
));
echo '<select name="'.$field['id'].'" id="'.$field['id'].'">
<option value="">Select One</option>'; // Select One
foreach($items as $item) {
echo '<option value="'.$item->ID.'"',$meta == $item->ID ? ' selected="selected"' : '','>'.$item->post_title.'</option>';
} // end foreach
echo '</select><br /><span class="description">'.$field['desc'].'</span>';
break;
} //end switch
echo '</td></tr>';
} // end foreach
echo '<tr><td><input id="publish" class="button button-primary button-large" type="submit" value="Update" accesskey="p" name="save"></td></tr>';
echo '</table>'; // end table
}
This way you can dynamically add and subtract teams. Don’t forget to loop through and save the data.