我正在使用下面的代码来弹出自定义帖子类型及其类别,所以
类别1---岗位1---岗位2
第二类——岗位1——岗位2——岗位3等。
这对我来说很好,但是我希望能够按count对我的类别进行排序,所以orderby=count,这样,在我下面的代码中不起作用的时候,具有大量帖子的类别将排在列表的顶部,知道为什么吗?
非常感谢您的帮助
<?php
// List posts by the terms for a custom taxonomy of any post type
$post_type = \'our_drinks\';
$tax = (\'our-drinks\');
$tax_terms = get_terms( $tax, \'orderby=count&order=ASC&hide_empty=0&hierarchical=true\');
if ($tax_terms) {
foreach ($tax_terms as $tax_term) {
$args = array(
\'post_type\' => $post_type,
"$tax" => $tax_term->slug,
\'post_status\' => \'publish\',
\'order\' => \'ASC\',
\'posts_per_page\' => -1,
\'caller_get_posts\'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) : ?>
<div class="category_title">
<?php echo $tax_term->name; ?>
</div>
<?php while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
LOOP CONTENT GOES HERE
<?php endwhile; ?>
v<?php else : ?>
<?php endif; // if have_posts()
wp_reset_query();
} // end foreach #tax_terms
}
?>