// Assuming ‘player’ is the custom post type for players and ‘team’ is for teams
// Add a meta box to the player edit screen for selecting the team
function add_team_selection_meta_box() {
add_meta_box(
‘team_selection_meta_box’,
‘Team Selection’,
‘render_team_selection_meta_box’,
‘player’,
‘side’,
‘default’
);
}
add_action(‘add_meta_boxes’, ‘add_team_selection_meta_box’);
// Render the team selection meta box
function render_team_selection_meta_box($post) {
// Retrieve the current team ID for the player
$selected_team = get_post_meta($post->ID, ‘selected_team’, true);
// Query teams to populate the select box
$teams = get_posts(array(‘post_type’ => ‘team’, ‘posts_per_page’ => -1));
// Output the select box
echo ‘‘;
echo ‘