if ('post' == $_POST['post_type']) { if (!current_user_can('edit_post', $post_id)) { return $post_id; } } // Update the fields $fields = [ 'nhl_game_id' => 'sanitize_text_field', 'game_post_type' => 'sanitize_text_field', 'away_projected_goalie' => 'sanitize_text_field', 'home_projected_goalie' => 'sanitize_text_field' ]; foreach ($fields as $field => $sanitize_callback) { if (isset($_POST[$field])) { $value = call_user_func($sanitize_callback, $_POST[$field]); update_post_meta($post_id, $field, $value); } } // Add debug logging error_log('Saving game post meta for post ID: ' . $post_id); error_log('NHL Game ID: ' . (isset($_POST['nhl_game_id']) ? $_POST['nhl_game_id'] : 'not set')); error_log('Game Post Type: ' . (isset($_POST['game_post_type']) ? $_POST['game_post_type'] : 'not set')); } add_action('save_post', 'save_game_post_meta');