Home › Forums › General Issues › How would I go about sorting by datepicker month,day (ignoring year) › Reply To: How would I go about sorting by datepicker month,day (ignoring year)
You cannot do this using just a date picker field because the year is part of the stored value and the year is the first part of the value.
In order to do this you would need to have another field where the month was first, followed by the day and then the year. This would be a non standard way to store a “date”.
What I would do is create an acf/save_post filter that took the ACF date field value and store that value in my non-standard format into another post meta field using standard WP meta/custom field functions. I would then use this new field in my WP_Query to allow ordering the posts by this field.
I posted a basic example here that shows how to do this. This example is for a repeater field, but the same principle can be applied to any field when you need some custom way to use the values in queries. https://acfextras.com/dont-query-repeaters/
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.