I have created a ne wpost type named “shows”, and assigned an ACF date field to it. While succeeding in displaying the posts and their details – I’m failing to sort them by date (the ACF date, not the post creation date).
Here is my code: http://codeshare.io/rpZIL
<ul id="shows-container">
<?php
$today = current_time('Ymd');
$args = array(
'post_type' => 'shows',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'show_date',
'compare' => '>=',
'value' => $today,
)
),
'meta_key' => 'show_date',
'orderby' => 'meta_value_num',
'order' => 'ASC'
);
//the query
$theshows = new WP_Query($args);
if($theshows->have_posts()):
while($theshows->have_posts()):
$theshows->the_post();
$showdate = get_field('show_date');
$showday = get_field('show_day');
$showhour = get_field('show_time');
$showloc = get_field('show_location');
$showphone = get_field('show_phone');
$showtickets = get_field('show_tickets');
?>
<li class="show-box">
<h3><?php the_title() ?></h3>
<div class="show-time">
<span class="show-date"><? echo $showdate ?></span>-<span class="show-day"><? echo $showday ?></span>-<span class="show-hour"><? echo $showhour ?></span>
</div>
<p class="show-address"><? echo $showloc ?></p>
<p class="show-phone"><? echo $showphone ?></p>
<a href="<? echo $showtickets ?>"><span><?php _e('Tickets','doliart');?></span></a>
</li>
<?php
endwhile;
else:
?>
Oops, there are no posts.
<?php
endif;
wp_reset_query(); ?>
</ul>