解决wordpress分类排序问题
.首先得往wordpress分类表里加入排序字段displayorder(类型为int).
经研究,此表为wp_terms.加完后,就给你需要排序的分类依次排序,结果如下:
2.打开wp-includes目录下taxonomy.php文件,由于wordpress的搜索逻辑默认没有对新加入的字段支持,得进行修改.
找到如下位置
- else if ( ‘name‘ == $orderby )
- $orderby = ‘t.name‘;
大概在615行,在这个位置下加入如下代码,以获得其对displayorder排序字段的支持
- else if ( ‘displayorder‘ == $orderby )
- $orderby = ‘t.displayorder‘;
3.在wp-content/themes目录下,找到你所用的模板目录,然后编辑sidebar.php页.这一步主要是往模板页里的分类函数加入排序方式的参数.
找到wp_list_categories函数,我的如下:
- <?php wp_list_categories(‘show_count=1&title_li=<h6>categories</h6>‘); ?>
修改为
- <?php wp_list_categories(‘orderby=displayorder&show_count=1&title_li=<h6>categories</h6>‘); ?>
done.

可以让displayorder这字段做索引
I agree with the suggestions in the article.
lol, yes, surely…
history again.
i love it.
Thankyou for sharing.
Thankyou for all your inspiration and for the goodness you spread.
Thank you for an inspiring post which has provided me with my motivation today!
cute very cute,,, love it very relaxing have a good one