WordPress get_posts order_by 标题不起作用

E. *_*ell 2 php wordpress

我有一个 get_posts 查询,它似乎没有正确排序。

$args = array(
            'post_type' => array(),
            'order_by' => 'title',
            'order' => 'ASC',
            'post_status' => 'publish',
            'posts_per_page' => -1,     
            'meta_query' => array(),
        );
Run Code Online (Sandbox Code Playgroud)

后面的几行填充了post_typemeta_query数组,但我认为不需要它们来说明问题。我告诉它按标题升序排序。然而,当查询返回时,我收到如下命令:

  • 凯文·斯塔尔
  • 山崎中村
  • 瑞德假日
  • 巨型水蚺
  • 卡西迪·克雷
  • 虎金
  • 布赖恩·弗瑞

这似乎没有任何规律或理由。我查过数据库,没有特殊字符。我什至运行了选择查询

SELECT * 
FROM  `prestige_posts` 
WHERE post_type =  'workers'
ORDER BY post_title
LIMIT 0 , 30
Run Code Online (Sandbox Code Playgroud)

手动并得到了我期望的确切结果。代码中的其他位置具有几乎完全相同的查询并且可以正常工作。那么为什么这不能正确返回呢?

IE 同一文件中的一个函数的示例确实返回正确:

$args = array(
                    'post_type' => $postType,
                    'orderby' => 'title',
                    'order' => 'ASC',
                    'post_status' => 'publish',
                    'posts_per_page' => -1, 
                    'post_parent' => $entry['id'],
                );
                $lastposts = get_posts($args);
Run Code Online (Sandbox Code Playgroud)

E. *_*ell 8

我只是个白痴。关键是orderby,我正在用order_by。这就是问题所在。我花了几个小时才发现它。