Hi glfoster,
Sorry for the delay getting back to you!
To query players from a roster you need to first extract the value of the roster meta field _wpcm_roster_players
.
If you know the id of the roster you are using then you can use (swap $id
for the roster ID):
$players = (array)unserialize( get_post_meta( $id, '_wpcm_roster_players', true ) );
which will return a comma separated array of players from the roster.
Then query wpcm_player post type as normal but adding 'post__in' => $players
to your query arguments.
Your query will then only return the players selected from the roster. If you need to add player stats then you will need to also extract the season and team associated with the roster using get_the_terms
. You can see how it is done in the Players shortcodes by checking out includes/shortcodes/class-wpcm-shortcode-player-list.php
I hope that helps and please feel free to express your love for the plugin in a review – https://www.ads-software.com/support/plugin/wp-club-manager/reviews/#new-post ??
Cheers
-
This reply was modified 4 years, 1 month ago by
Leon.