Skip to content

Instantly share code, notes, and snippets.

@dcooney
Last active May 30, 2016 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcooney/357246e89c9e1b8ed4dc3bf395c07406 to your computer and use it in GitHub Desktop.
Save dcooney/357246e89c9e1b8ed4dc3bf395c07406 to your computer and use it in GitHub Desktop.
<div class="shows-list-wrap">
<?php
$currentdate = date('Ymd');
$args = array(
'posts_per_page' => -1,
'post_type' => 'concert_type',
'order' => 'asc',
'orderby' => 'meta_value_num',
'meta_query' => array(
array(
'key' => 'concert_date',
'value' => $currentdate,
'compare' => '>=',
),
),
);
$cpt_query = new WP_Query($args);
?>
<?php if ($cpt_query->have_posts()) : while ($cpt_query->have_posts()) : $cpt_query->the_post(); ?>
<?php
global $post;
$date = get_field( 'concert_date' , $post->ID, false);
// make date object
$date = new DateTime($date);
?>
<div class="shows-list">
<?php the_title(); ?> <span>- <?php echo $date->format( 'n/d' ); ?></span>
</div> <!-- /shows-list -->
<?php endwhile; endif; // end of CPT loop ?>
<?php wp_reset_postdata(); ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment