I realise this is leaning towards a straight up WP question rather than an ACF question but my query uses two ACF and the query is sorted by both, and the issue is connected to one of them! Hopefully you can help 🙂
I have the following code which loops through Woocommerce products and orders them by two ACF – firstly by start date (which is a date picker field) and then secondly by duration (text input field). This works fine – except for tours that don’t have start dates assigned. These are output at the top of the list, and I’d like them to be at the bottom of the list of results, so that the user sees the items with start dates assigned first. Any ideas how to amend this query to achieve that?
Do your query as you are doing it and add a posts_results filter. In this filter you short the posts into two arrays: those that have a start date and those don’t have a start date. Then you merge the two arrays and return the resorted posts.
Viewing 4 posts - 1 through 4 (of 4 total)
The topic ‘Send posts that have a specific ACF meta field empty to the bottom’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users