我有一个 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_type和meta_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)
| 归档时间: |
|
| 查看次数: |
6270 次 |
| 最近记录: |