您需要按照什么标准对分类术语进行排序?
请参阅此参数数组键:
\'orderby\' => $orderby,
根据文件
wp_list_categories()
, 这个
orderby
参数可以采用以下值:
\'ID\'
- 默认值\'name\'
\'slug\'
\'count\'
\'term_group\'
注意,您可能还需要添加
order
参数:
\'orderby\' => \'ASC\',
此参数采用:
EDIT
如果我想按ID订购,我会怎么做?
使用您的代码:
<?php
//list terms in a given taxonomy using wp_list_categories (also useful as a widget if using a PHP Code plugin)
$taxonomy = \'workcategories\';
// THIS IS THE PARAMETER TO CHANGE
// CHANGE IT FROM \'name\' TO \'ID\'
// (NOTE CASE)
$orderby = \'ID\';
// ADD THE \'order\' PARAMETER, TO
// SPECIFY WHETHER TO SORT ASCENDING
// OR DESCENDING (AGAIN: NOTE CASE)
$order = \'ASC\' // \'ASC\' for ascending, \'DESC\' for descending
$show_count = 0; // 1 for yes, 0 for no
$pad_counts = 0; // 1 for yes, 0 for no
$hierarchical = 1; // 1 for yes, 0 for no
$title = \'\';
$args = array(
\'taxonomy\' => $taxonomy,
\'orderby\' => $orderby,
// DON\'T FORGET TO ADD THE \'order\' PARAMETER HERE, TOO
\'order\' => $order,
\'show_count\' => $show_count,
\'pad_counts\' => $pad_counts,
\'hierarchical\' => $hierarchical,
\'title_li\' => $title
);
?>
ID不是按数字顺序运行的。
嗯,那没有道理。ID是数值的,因为它们是整数。因此,订购方式ID
以数字顺序生成ID的升序列表或降序列表。