Home › Forums › ACF PRO › WP_Query orderby ACF date picker field › Reply To: WP_Query orderby ACF date picker field
I have the same issue – also trying to order by a custom date field. So the code looks almost identical. I have orderby written correctly but still have this issue.
I’ve also tried ‘orderby’ => ‘meta_value’ and ‘orderby’ => ‘meta_value_num’ with no difference.
My args are:
$args = array(
‘post_type’ => array( $post_type ),
‘post_status’ => array( ‘publish’ ),
‘posts_per_page’ => -1,
‘tax_query’ => array(
array (
‘taxonomy’ => $taxonomy,
‘terms’ => $term_id,
)
),
‘meta_query’ => array(
array(
‘key’ => ‘date’,
‘compare’ => ‘>=’,
‘value’ => $date_now,
‘type’ => ‘DATETIME’
),
),
‘order’ => ‘DESC’,
‘orderby’ => ‘meta_value’,
‘meta_key’ => ‘date’,
‘meta_type’ => ‘DATETIME’,
);
I’d be grateful if you have any pointers 🙂
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.