Home › Forums › Front-end Issues › Displaying based on multiple date fields › Reply To: Displaying based on multiple date fields
I looked at this when you first posted, but I don’t really have an answer. It looks like you are trying to order the posts by two different fields as if they are one field. You can do a query to make sure that one of the fields is in the correct range, but you can’t order them by the values in these field….. well, you can, but not at the same time. For example, you could order them by the “end date” and then order them by the “start date”, or you can order them by “end date 1” and then by “end date 2”. Hopefully I’ve explained this well enough that you see the problem.
If you need to order by both of these fields then your best bet is to do what you suggest. Create an acf/save_post filter that looks at the date fields and takes the one you want to sort by and puts them into another custom meta field using
update_post_meta() and then order the posts by this single field.
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!
CPT registration is coming to ACF! We demoed the new feature during the most recent session of ACF Chat Fridays. Check out the summary for the details. https://t.co/k2KQ3WWBAz— Advanced Custom Fields (@wp_acf) March 7, 2023
© 2023 Advanced Custom Fields.