Php WordPress获取帖子按标题排序不起作用
我有一个get_posts查询,似乎排序不正确Php WordPress获取帖子按标题排序不起作用,php,wordpress,Php,Wordpress,我有一个get_posts查询,似乎排序不正确 $args = array( 'post_type' => array(), 'order_by' => 'title', 'order' => 'ASC', 'post_status' => 'publish', 'posts_per_page' => -1, 'm
$args = array(
'post_type' => array(),
'order_by' => 'title',
'order' => 'ASC',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_query' => array(),
);
后面有一些行填充了post_类型
和meta_查询
数组,但我认为不需要它们来说明问题。我告诉你这是按标题升序排序的。然而,当查询返回时,我得到如下顺序:
- 凯文·斯塔尔
- 山崎中村
- 瑞德假日酒店
- 巨蟒
- 卡西迪·克雷
- 老虎金
- 布莱恩·弗瑞
SELECT *
FROM `prestige_posts`
WHERE post_type = 'workers'
ORDER BY post_title
LIMIT 0 , 30
手动操作并获得我期望的准确结果。代码中的其他位置具有几乎完全相同的查询,并且工作正常。那么,这为什么不能正常返回呢
例如,同一文件中的一个函数返回正确的示例:
$args = array(
'post_type' => $postType,
'orderby' => 'title',
'order' => 'ASC',
'post_status' => 'publish',
'posts_per_page' => -1,
'post_parent' => $entry['id'],
);
$lastposts = get_posts($args);
我只是个白痴。
关键是orderby
,我使用的是orderby
。这就是问题所在。我花了几个小时才发现它。我只是个白痴。
关键是orderby
,我使用的是orderby
。这就是问题所在。我花了几个小时才发现