I'm using the ACF pro date & time picker to populate the field "fixture_date" for the custom post type "fixtures". Running a new wp_Query
returns all of the posts but I cant sort them by the custom field's date & time.
The date & time picker is set to output as j F Y - g:i a
from within ACF Pro.
My code so far:
<table id="fixturestable">
<tbody>
<?php $args = array(
'post_type' => 'fixtures',
'posts_per_page' => -1,
'orderby' => 'meta_value',
'meta_key' => 'fixture_date',
'order' => 'ASC',
'meta_type' => 'DATETIME'
);
$fixturesloop = new WP_Query( $args ); if ($fixturesloop->have_posts() ):?>
<?php while ( $fixturesloop->have_posts() ) : $fixturesloop->the_post();?>
<tr>
<td class=""><?php the_title(); ?></td>
<td class=""><?php echo(get_field('fixture_date'));?></td>
<td class=""><?php echo(get_field('competition'));?></td>
<td class=""><?php echo(get_field('venue'));?></td>
<td class=""><?php echo(get_field('result'));?></td>
<td class=""><?php echo(get_field('score'));?></td>
</tr>
<?php endwhile;?>
<?php endif;?>
</tbody>
</table>