Click here to Skip to main content
15,892,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to sort post by different fields. If date is not pass percent not important and just date is important but if date passed I wanna sort by percent. How I can do this with
WP_Query

The bare query I want use is this:

select *, end_date < now() as flag from posts
order by flag
, case when flag = 0 then end_date end desc
, case when flag = 1 then project_percent end desc;


What I have tried:

In other word, I want to use this query with WP_Query.
Posted
Comments
Herman<T>.Instance 31-Oct-16 8:47am    
sql ends with ORDER BY. Your query makes no sense

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900