将默认wordpress查询更改为order by title [英] change default wordpress query to orderby title

查看:106
本文介绍了将默认wordpress查询更改为order by title的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在查看某个类别时将wordpress默认查询更改为orderby标题,而不是帖子ID。

I would like to change the wordpress default query to orderby title when viewing a category, rather than the post id.

由于太无聊的原因无法解释(!)我想改变默认设置,而不是使用自定义查询(我知道该怎么做)。

For reasons too boring to explain(!) I would like to change the default setting rather than use a custom query (which I know how to do)

理想情况下,这将是functions.php中的一些代码我的模板,而不是不得不破解核心安装。

Ideally it would be some code that goes in the functions.php of my template, rather than having to hack the core installation.

感谢您的帮助!

推荐答案

在您的archive.php中,找到代码

in your archive.php, find the code

if (have_posts()) : while (have_posts()) : the_post();

并将其替换为:

and replace it with:

$cat_posts = new WP_Query($query_string."&orderby=title&order=ASC");
if ($cat_posts->have_posts()):while($cat_posts->have_posts()):$cat_posts->the_post();

这应该可以做到。

更新:如果您想更改源代码,则需要执行此操作。

update: this is taken if you want to change the source code.

这篇关于将默认wordpress查询更改为order by title的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆