Im try to make a custom SportsPress player list with PHP and I want to get all players from one team. But it doesn’t show any post, even not all players.
There’s the code:
<?php
$query = new WP_Query( array(
'post_type' => 'sp_player',
'tax_query' => array(
array(
'taxonomy' => 'sp_team',
'field' => 'team',
'terms' => 197,
)
),
) );
if ( $query->have_posts() ) : ?>
<?php while ( $query->have_posts() ) : $query->the_post();
$staff = new SP_Staff( $post->ID );
$current_teams = $staff->current_teams();
foreach ( $current_teams as $team ):
$team_name = sp_get_team_name( $team, $abbreviate_teams );
if ( $link_teams ) $team_name = '<a href="' . get_post_permalink( $team ) . '">' . $team_name . '</a>';
$teams[] = $team_name;
endforeach;
?>
<?php the_title(); ?> ( <? echo $team_name; ?> ) - <?php the_date('d.m.Y', '', ''); ?> <br/>
<?php endwhile; wp_reset_postdata(); ?>
<?php endif; ?>
If I filter from post list at Admin dashboard it shows this link
http://www.example.com/wp-admin/edit.php?s
&post_status=all
&post_type=sp_player
&action=-1&m=201708
&tax_input%5Bsp_position%5D%5B0%5D=0
&tax_input%5Bsp_league%5D%5B0%5D=0
&tax_input%5Bsp_season%5D%5B0%5D=0
&team=197
&sp_season=2017
&filter_action=Filter
&paged=1
&action2=-1
And the post type slug for all teams ir sp_team