Is it possible using WP_Query to return a filtered list of items based on the following criteria set? I seem to be struggling as there are numerous queries against custom fields.
Select all posts that are of type business_club (post_type)
Where the post has a zone of 'Asia' (meta_value)
Order by country ASC (meta_value)
then by town ASC (meta_value)
then by title (wp value)
Any help is greatly appreciated.
Did you try something like this:
I don’t know yet if you can do the then orderby town and title.
If all results have the same zone, why would you want to order by zone?
As far as I know, you can’t include two meta_keys in a single query. So you’ll have to write the query to return the results ordered by title, save them in an array, and then resort the array into the order you need using PHP.
The way around it was to build a custom query. More information on this can be viewed on the WordPress codex at http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query.
My final code looked as follows