ACF Sort By Datepicker WP Query to Run
Sort By Datepicker on Advanced Custom Fields - ACF. Simple and Fast Method.
I was struggling to get ACF to sort my post based on the datepicker that they provide. I was finally able to do it. This is the snippet that you can use so you can sort items.
$args = array(
'meta_key' => 'playingon', // name of custom field
'orderby' => 'meta_value_num',
'order' => 'ASC',
'posts_per_page' => -1,
'cat' => '3'
);
$event_query = new WP_Query( $args );
// The Loop
if ( $event_query->have_posts() ) { ?>
<div class="container-fluid div1HP">
<div class="row">
<div class="col">
<h2 class="white serif">Playing Now </h2>
<subhead>At the Remarkable Theater</subhead>
</div>
</div>
</div>
<?php
while ( $event_query->have_posts() ) {
$event_query->the_post();
get_template_part( 'template-parts/content', get_post_type() );
?>
<?php
}
}else{
}
// Restore original Post Data
wp_reset_postdata();
?>