Wordpress wp_query orderby not working

时间:2016-04-25 12:46:26

标签: php sql wordpress

我试图让订单在wp_query中工作,但是仍然使用默认设置订购帖子(只是tag__in正在运行)。对帖子的SQL查询如下所示:

<tbody

以下是代码段:

string(379) "SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (81) ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 3" 

谢谢!

2 个答案:

答案 0 :(得分:1)

我已检查过您必须传递错误参数的代码。

您可以查看以下代码吗?

<强>错误

a

从右

'order'=>'ID',
'orderby'=>'ASC',

答案 1 :(得分:0)

好的,我切换了订单和订单... 所以,正确的参数是'orderby'=&gt;'ID','order'=&gt;'ASC',