Last active
December 4, 2016 23:20
-
-
Save ciaranha/d8004cdd0604ce77e9079ce1a2f4f7a4 to your computer and use it in GitHub Desktop.
Order Custom Post Types by ACF values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
'posts_per_page' => 5, | |
'post_type' => 'sports', | |
'meta_key' => 'event_type', | |
'meta_value' => 'Match', | |
'orderby' => array( | |
'match_date' => 'ASC', | |
) | |
); | |
$wp_query = new WP_Query( $args );?> | |
<?php if ( $wp_query->have_posts() ) : ?> | |
<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?> | |
<div class="match"> | |
<a class="match-link" href="<?php echo get_permalink(); ?>"> | |
<div class="match-details"> | |
<span class="sport"> | |
<?php the_field('sport'); ?> | |
</span> | |
<span class="match-date"> | |
<?php the_field('match_date'); ?> | |
</span> | |
</div> | |
<div class="result"> | |
<div class="team-name team-name-left"> | |
<?php the_field('team_one'); ?> | |
</div> | |
<div class="text-center"> | |
<?php if( get_field('team_one_score') ): ?> | |
<div class="scores"> | |
<span class="team-score"><?php the_field('team_one_score'); ?></span> - | |
<span class="team-score"><?php the_field('team_two_score'); ?></span> | |
</div> | |
<?php else : ?> | |
<div class="match-time"> | |
<?php the_field('match_time'); ?> | |
</div> | |
<?php endif; ?> | |
</div> | |
<div class="team-name team-name-right"> | |
<?php the_field('team_two'); ?> | |
</div> | |
</div> | |
</a> | |
</div> | |
<?php endwhile; ?> | |
<?php else : ?> | |
<h3>There are no recent or upcoming matches</h3> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment