开发者

Sorting problem with 'query_posts' function in wordpress. Sort by custom field not working

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 co开发者_如何学Pythonmmand:

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.


You need to make sure that you have the correct meta_key name used in the query. You say that the custom field is called starting_time but you set order_by to start_date in your code.

The order seems ok at ASC as this will show next up event.


The problem was with the order_by command :) it is not order_by but orderby.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜