WordPress 搜索结果顺序
我在结果分页方面遇到问题。我需要按标题和字母顺序(A->Z)对结果进行排序,这可能吗?我尝试了一些不同的方法,但没有一个能根据需要工作,到目前为止,我最好的方法是按标题和 ASC 列出结果,但如果我转到“下一页”,我总是得到相同的结果。
有什么想法吗?
谢谢。
I have a problem with pagination on results. I need to order the results by title and by alphabetic order (A->Z) , its possible? I tried some different approaches but none work as needed, the best i have so far is list the results by title and ASC but if i go to "next page" i get always the same results.
Any idea?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来您走在正确的轨道上,但您在每个页面上都得到相同的结果,因为 Wordpress 正在丢失其内部页面的跟踪。这是通过 $paged 全局来完成的。
如果您要使用 query_posts 修改排序,请确保您还传入全局 $paged var ('&paged='.$paged )。另外,在query_posts中调用之前,请确保页面上也存在global,否则它将始终为0并在每个页面上返回相同的结果。如果您使用 WP_Query 而不是 query_posts,这是一个很好的运行。 http://weblogtoolscollection.com/archives/2008/ 04/19/分页和自定义 wordpress-loops/
It looks like you are on the right track but you are getting the same results on each page because Wordpress is losing track of what page it is on internally. This is done with the $paged global.
If you are modifying the sorting with query_posts, make sure you are also passing in the global $paged var ('&paged='.$paged ). Also, make sure that global exists on the page as well before calling it in query_posts, otherwise it will always be 0 and return the same results on each page. If you are using WP_Query instead of query_posts, this is a good run down. http://weblogtoolscollection.com/archives/2008/04/19/paging-and-custom-wordpress-loops/
这就是我正在使用的,将其添加到index.php
在您的情况下,您可能还需要添加 is_home() 条件
希望它有帮助:)
This is what I'm using, add it on index.php
In your case, you might also need to put is_home() condition
Hope it helps :)