$name, 'labels' => $labels, 'public' => true, 'hierarchical' => false, 'supports' => array( 'title', 'author', 'comments', 'page-attributes' ), 'register_meta_box_cb' => 'sp_event_meta_init', 'rewrite' => array( 'slug' => 'event' ) ); register_post_type( 'sp_event', $args ); } add_action( 'init', 'sp_event_cpt_init' ); function sp_event_display_scheduled( $posts ) { global $wp_query, $wpdb; if ( is_single() && $wp_query->post_count == 0 && isset( $wp_query->query_vars['sp_event'] )) { $posts = $wpdb->get_results( $wp_query->request ); } return $posts; } add_filter( 'the_posts', 'sp_event_display_scheduled' ); function sp_event_meta_init() { remove_meta_box( 'submitdiv', 'sp_event', 'side' ); add_meta_box( 'submitdiv', __( 'Event', 'sportspress' ), 'post_submit_meta_box', 'sp_event', 'side', 'high' ); add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sp_event_team_meta', 'sp_event', 'normal', 'high' ); add_meta_box( 'sp_articlediv', __( 'Article', 'sportspress' ), 'sp_event_article_meta', 'sp_event', 'normal', 'high' ); } function sp_event_team_meta( $post, $metabox ) { global $post_id; $limit = get_option( 'sp_event_team_count' ); for ( $i = 0; $i < $limit; $i++ ): $selected = array_pad( array_slice( (array)get_post_meta( $post_id, 'sp_team', false ), 0, $limit ), $limit, 0); $args = array( 'post_type' => 'sp_team', 'name' => 'sportspress[sp_team][]', 'selected' => $selected[ $i ] ); wp_dropdown_pages( $args ); echo '
' . PHP_EOL; /* $players = unserialize( get_post_meta( $post_id, 'sp_players', true ) ); ?>

post_content, 'content' ); } function sp_event_edit_columns( $columns ) { $columns = array( 'cb' => '', 'title' => __( 'Event', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ), 'sp_league' => __( 'Leagues', 'sportspress' ), 'sp_season' => __( 'Seasons', 'sportspress' ), 'sp_sponsor' => __( 'Sponsors', 'sportspress' ), 'sp_kickoff' => __( 'Kick-off', 'sportspress' ) ); return $columns; } add_filter( 'manage_edit-sp_event_columns', 'sp_event_edit_columns' ); function sp_event_edit_sortable_columns( $columns ) { $columns['sp_kickoff'] = 'sp_kickoff'; return $columns; } add_filter( 'manage_edit-sp_event_sortable_columns', 'sp_event_edit_sortable_columns' ); function sp_event_request_filter_dropdowns() { global $typenow, $wp_query; if ( $typenow == 'sp_event' ) { // Leagues $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null; $args = array( 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ), 'taxonomy' => 'sp_league', 'name' => 'sp_league', 'selected' => $selected ); sp_dropdown_taxonomies( $args ); echo PHP_EOL; // Seasons $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null; $args = array( 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ), 'taxonomy' => 'sp_season', 'name' => 'sp_season', 'selected' => $selected ); sp_dropdown_taxonomies( $args ); echo PHP_EOL; // Sponsors $selected = isset( $_REQUEST['sp_sponsor'] ) ? $_REQUEST['sp_sponsor'] : null; $args = array( 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Sponsors', 'sportspress' ) ), 'taxonomy' => 'sp_sponsor', 'name' => 'sp_sponsor', 'selected' => $selected ); sp_dropdown_taxonomies( $args ); } } add_action( 'restrict_manage_posts', 'sp_event_request_filter_dropdowns' ); ?>