I want list all the upcoming and past events(custom posts) in chronological order. I have saved data by meta key start_time,duration ,
I try to use sql ,but can not get there!
Thanks for any help in advance!
|
I want list all the upcoming and past events(custom posts) in chronological order. I have saved data by meta key start_time,duration , I try to use sql ,but can not get there! Thanks for any help in advance! |
|||
|
Try to use Simple example would be like:
and use a simple See this for more info on meta query parameters. |
|||
|
orderbyparameter of your query tometa_value_num. – pogoking Jan 9 at 3:51SELECT (SELECT ABS(m1.meta_value-UNIX_TIMESTAMP(NOW())) from wp_postmeta AS m1 WHERE m1.meta_key='st_time' AND m1.post_id=p.ID) AS dis FROM wp_posts AS p, wp_postmeta AS m WHERE p.ID = m.post_id ORDER BY dis,the query_post() may not have so much! – liying Jan 9 at 6:41