$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', 'side', 'high' ); add_meta_box( 'sp_articlediv', __( 'Article', 'sportspress' ), 'sp_event_article_meta', 'sp_event', 'normal', 'high' ); } function sp_event_team_meta( $post ) { $limit = get_option( 'sp_event_team_count' ); $teams = array_pad( array_slice( (array)get_post_meta( $post->ID, 'sp_team', false ), 0, $limit ), $limit, 0); $scores = array_pad( array_slice( (array)get_post_meta( $post->ID, 'sp_score', false ), 0, $limit ), $limit, 0); $players = (array)get_post_meta( $post->ID, 'sp_player', false ); for ( $i = 0; $i < $limit; $i++ ): ?>
'sp_team', 'name' => 'sportspress[sp_team][]', 'class' => 'sportspress-pages', 'show_option_none' => sprintf( __( 'Select %s' ), 'Team' ), 'option_none_value' => 0, 'selected' => $teams[ $i ] ); wp_dropdown_pages( $args ); ?>
ID, 'sp_player', false, 'block', 'sp_team', $i ); sp_post_checklist( $post->ID, 'sp_staff', $i == $limit - 1, 'none', 'sp_team', $i ); ?>