Home › Forums › General Issues › Sort posts in a widget using 2 ACFs › Reply To: Sort posts in a widget using 2 ACFs
Some issues with your current code.
ACF does not store date fields in the DB as dates. It saves strings that are in the format of ‘Ymd’, so using a type of “DATE” will produce errors.
If you want to sort by the second field then that field must have a value in the DB (even if that value is an empty string). WP will ignore any posts that do not have a value set for a field. I’m not sure what you mean by optional, but in this case the field would always need to be visible and allow no input.
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.