我试着定制SportsPress 球员名单与PHP,我想得到所有球员从一个团队。但它并没有显示任何帖子,甚至不是所有的球员。
代码如下:
<?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; ?>
如果我从管理仪表板的帖子列表中筛选,它会显示此链接
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
以及所有球队的post-type slug ir
sp_team