[
‘name’ => ‘Players’,
‘singular_name’ => ‘Player’,
‘add_new’ => ‘Add New’,
‘add_new_item’ => ‘Add New Player’,
‘edit_item’ => ‘Edit Player’,
‘new_item’ => ‘New Player’,
‘view_item’ => ‘View Player’,
‘search_items’ => ‘Search Players’,
‘not_found’ => ‘No players found’,
‘not_found_in_trash’ => ‘No players found in Trash’,
‘all_items’ => ‘All Players’,
‘menu_name’ => ‘Players’,
‘name_admin_bar’ => ‘Player’,
],
‘public’ => true,
‘has_archive’ => false,
‘show_in_rest’ => true,
‘supports’ => [‘title’, ‘editor’],
‘taxonomies’ => [‘category’], // Optional for filtering by position or team
‘menu_position’ => 5,
]);
// Draft Picks Post Type
register_post_type(‘draft_picks’, [
‘labels’ => [
‘name’ => ‘Draft Picks’,
‘singular_name’ => ‘Draft Pick’,
‘add_new’ => ‘Add New’,
‘add_new_item’ => ‘Add Draft Pick’,
‘edit_item’ => ‘Edit Draft Pick’,
‘new_item’ => ‘New Draft Pick’,
‘view_item’ => ‘View Draft Pick’,
‘search_items’ => ‘Search Draft Picks’,
‘not_found’ => ‘No draft picks found’,
‘not_found_in_trash’ => ‘No draft picks found in Trash’,
‘all_items’ => ‘All Draft Picks’,
‘menu_name’ => ‘Draft Picks’,
‘name_admin_bar’ => ‘Draft Pick’,
],
‘public’ => true,
‘has_archive’ => false,
‘show_in_rest’ => true,
‘supports’ => [‘title’],
‘menu_position’ => 6,
]);
}
add_action(‘init’, ‘register_fantasy_draft_cpts’);
// Create Custom Fields for Players (using Advanced Custom Fields plugin)
function register_player_custom_fields() {
if( function_exists(‘acf_add_local_field_group’) ) {
acf_add_local_field_group([
‘key’ => ‘group_1’,
‘title’ => ‘Player Details’,
‘fields’ => [
[
‘key’ => ‘field_position’,
‘label’ => ‘Position’,
‘name’ => ‘position’,
‘type’ => ‘text’,
‘required’ => true,
],
[
‘key’ => ‘field_position_rank’,
‘label’ => ‘Position Rank’,
‘name’ => ‘position_rank’,
‘type’ => ‘number’,
‘required’ => true,
],
[
‘key’ => ‘field_overall_rank’,
‘label’ => ‘Overall Rank’,
‘name’ => ‘overall_rank’,
‘type’ => ‘number’,
‘required’ => true,
],
[
‘key’ => ‘field_team’,
‘label’ => ‘Team’,
‘name’ => ‘team’,
‘type’ => ‘text’,
‘required’ => true,
],
],
‘location’ => [
[
[
‘param’ => ‘post_type’,
‘operator’ => ‘==’,
‘value’ => ‘players’,
],
],
],
]);
}
}
add_action(‘init’, ‘register_player_custom_fields’);