wordpress :: WP_QUERY 不按标题对帖子进行排序
我正在使用 WP_QUERY 来获取帖子。问题是我想按标题对帖子进行排序,但出了问题。我可以得到帖子但没有排序。
我跟踪了 WP_QUERY 类,发现这是它生成的选择查询,
SELECT SQL_CALC_FOUND_ROWS wp_posts . *
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 ( 4, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 )
)
AND wp_posts.post_type = 'ecommerce'
AND (
wp_posts.post_status = 'publish'
OR wp_posts.post_status = 'private'
)
GROUP BY wp_posts.ID
ORDER BY `wp_posts`.`post_title` ASC
LIMIT 0 , 10
很明显它是按帖子标题正确排序的,但我不确定问题是什么,
有什么帮助吗?
谢谢
i'm using WP_QUERY to get posts. the problem is that i want to sort the posts by title, but something is going wrong. i could get the posts but not sorted.
i traced WP_QUERY class and i found that this is the select query that it produced
SELECT SQL_CALC_FOUND_ROWS wp_posts . *
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 ( 4, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 )
)
AND wp_posts.post_type = 'ecommerce'
AND (
wp_posts.post_status = 'publish'
OR wp_posts.post_status = 'private'
)
GROUP BY wp_posts.ID
ORDER BY `wp_posts`.`post_title` ASC
LIMIT 0 , 10
it's obvious that it's ordering by post title correctly, but i'm not sure what is the problem
any help ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许某些标题的左侧字符中有空格。你可以尝试一下:
Perhaps some titles have spaces in the left characters. Can you try with: