Home › Forums › General Issues › How to order by date field › Reply To: How to order by date field
After looking on the internet for the last 4 hours, I finally figure it out. You have to put the orderby metadata first, then add a meta_query array to filter through the posts.
$args = array (
'post_type' => 'route',
'meta_key' => 'trip_start_date',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_query' => array(
array(
'meta_key' => 'route_status',
'compare' => '=',
'value' => 'not-yet-launched',
),
),
'posts_per_page' => '9',
);
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.