Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $tournaments = get_field( 'tournament_selection' );
- var_dump( $tournaments );
- function format_tournament( $id ) {
- $date = DateTime::createFromFormat( 'Ymd', get_field('tournament_date', $id) );
- return sprintf( '<li><a href="%s">%s</a><span>%s</span></li>', get_permalink($id), get_field('tournament_name', $id), $date->format('F d, Y') );
- }
- if( $tournaments ) {
- $upcoming = '';
- $finished = '';
- foreach( $tournaments as $tournament ) {
- $terms = wp_get_object_terms( $tournament, 'category', array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'slug') );
- if( in_array( 'upcoming-tournament', $terms ) ) {
- $upcoming .= format_tournament( $tournament );
- }
- if( in_array( 'finished-tournament', $terms ) ) {
- $finished .= format_tournament( $tournament );
- }
- }
- ?>
- <h3>Upcoming Tournaments</h3>
- <ul><?php echo $upcoming; ?></ul>
- <h3>Finished Tournaments</h3>
- <ul><?php echo $finished; ?></ul>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement