0 down vote favorite
Hi, I am working with wordpress where i have a event listing system. There is a custom field in my post called starting_time which is unix timestamp. Now i want to short all posts by starting_time by this query_post command:
query_posts(array(
'post_type' => 'event',
'meta_key' => 'end_time',
'meta_compare' =>'>=',
'meta_value'=>time(),
'order_by' => 'start_date',
'order' => 'ASC'
));
But it not working. Here is the site http://citystir.com/events/. I am echoing the start_time in unix before the time remaining so you can see the value. And also my pagination is not working. May be i did something wrong in the query_post command.
Please someone response.
--------------------- Update -----------------
i have found a wonderful post here kovshenin.com/archives/customize-posts-order-in-wordpress-via-custom-fields but i didn't get it worked. May be for lack of my knowledge. Please take a look at it and let me know if you have any suggestions. I will continue working on that.
-------------------- Resolved -----------------
Changed order_by to orderby. And also i came to know that we can use meta key multiple times if we want it will not conflict. Here is the final code:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts(array(
'post_type' => 'event',
'meta_key' => 'end_time',
'meta_compare' =>'>=',
'meta_value'=>time(),
'meta_key' => 'start_time',
'orderby' => 'meta_value_num',
'post_per_page' => '-1',
'order' => 'ASC',
'paged' => $paged
));
Thanks for all your hard work!
var_dump(array('meta_key' => 'end_time', 'meta_key' => 'start_time'));