我使用以下代码显示子类别中的数据。子类别为“英国”、“仅英格兰”、“仅北爱尔兰”、“仅苏格兰”、“仅威尔士”。
按日期或asc/desc排序,英国子类别位于中间位置,威尔士或英格兰位于顶部。我需要英国子类别位于顶部。它拥有最多的帖子-那么可以在查询中使用orderby来解决这个问题吗?或者你认为我只需要为UK子类别创建自己的循环吗?
$parentCatID = get_cat_ID(\'Grants and Incentives\');
$childCats = get_categories( \'child_of=\'.$parentCatID.\'&orderby=date&order=asc\' );
if(is_array($childCats)):
foreach($childCats as $child){ ?>
<h2 class="experts <?php echo $child->name; ?>"><?php echo $child->name; ?> Grants and Incentives</h2>
<?php query_posts(\'cat=\'.$child->term_id.\'&post_type=grants-and-incentive\');
while(have_posts()): the_post(); $do_not_duplicate = $post->ID;
编辑:我现在正在使用Category Order and Taxonomy Terms Order Plugin 和orderby=term_order. 这很有效。如果有人能解释的话,如果不使用插件就知道它是如何工作的,那就太好了!