I'm using wordpress, want first-level taxonomy terms to be ordered by name but below code is not giving me desired result. Here is my code:
$args = array(
'taxonomy' => 'tax-category',
'hide_empty' => 0,
'hierarchical' => 1,
'parent' => 0,
'orderby'=>'name',
'order' => 'DESC',
'fields' => 'all',
);
$rs_terms = get_terms('tax-category', $args);
When I'm adding below php sorting, it works perfectly. But want to know why wordpress's default sorting is not working properly:
usort($rs_terms, function($a, $b){
return strcmp($a->name, $b->name);
});