Home › Forums › General Issues › How to order by date field › Reply To: How to order by date field
Ok, tried this:
<?php
$today = date('MM d, yy');
$args = array (
'post_type' => 'post',
'meta_query' => array(
array(
'meta_key' => 'event_date',
'compare' => '>=',
'value' => $today,
),
array(
'meta_key' => 'event_date',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'cat' => '2'
)
),
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post(); ?>
But it does not return the correct result. It shows all the events.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.