Home › Forums › General Issues › Sort CPT with multiple dates › Reply To: Sort CPT with multiple dates
Does each Course have a repeater field with multiple dates in it or have you created multiple courses with the same name that have a different date assigned to them?
You could do something like this to get all courses after today:
$today = date( 'Y-m-d' );
$args = array(
'post_type' => 'course',
'meta_query' => array(
array(
'key' => 'course_date',
'value' => $today,
'compare' => '>=',
'type' => 'DATE'
)
)
):
$query = new WP_Query( $args );
Note: the ‘key’ would be your ACF field name that contains the date. You may need to adjust the format of the date.
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.