<ul class="car_side_menu">
<?php $cats = get_categories(array(
'post_type' => 'post',
'taxonomy' => 'blog_chiiki' ,
//'orderby' => 'count',//順番は指定します
'hide_empty' => 1 ,//記事がなくとも表示
// 'pad_counts' => true,
//'depth' => 1,//子は表示しません。
));
$amounts = array();
foreach ($cats as $v):
$amounts[] = $v -> category_count;
endforeach;
array_multisort($amounts,SORT_DESC, SORT_NUMERIC, $cats);
?>
<?php if(!empty($cats)):
?>
<div class="d_tag_side">
<h3>作業日報 地域:</h3>
<?php
// echo "<pre>";
// print_r($cats);
// echo "</pre>";
//$counts = array();
?>
<?php foreach($cats as $tag) {?>
<?php
echo '<a href="'. get_term_link($tag->term_id) .'">'. $tag->name
.' ('. $tag->count
.")</a>
";
} ?>
</div>
<?php endif; ?>
</ul>
<br>
<br>
ライフサービス追加 サイドバー 日報地域だが
get categories のカウントが何故か効かない 並び替えがそもそもできない。なので強制並び替え成功コード
https://wpdocs.osdn.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/get_categories