Home › Forums › Add-ons › Repeater Field › ACF query posts by date sub field › Reply To: ACF query posts by date sub field
I had a similar issue recently also working on show listings.
You can do a regular query retrieving the posts then do a get_fields for all fields of that post, then sort the array. Check out Answer 1 below for that one.
https://stackoverflow.com/questions/2699086/sort-multi-dimensional-array-by-value
I chose to create a custom query joining to the postmeta table twice. Once for the date and once for the time. Like
SELECT * WPPREFIX_posts p
INNER JOIN WPPREFIX_postmeta m1 ON p.ID = m1.post_id
INNER JOIN WPPREFIX_postmeta m2 ON p.ID = m2.post_id
WHERE m1.meta_key = 'start_date' AND m2.meta_key = 'start_time'
ORDER BY m1.meta_value,m2.meta_value
This allows you to sort by each meta value.
Hope this helps
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.