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!
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.