php args array orderby name alphabetical order ASC starting at hide_em

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
$args = array(
'orderby' => 'name', // alphabetical
'order' => 'ASC', // starting at A
'hide_empty' => 1,
'show_count' => 0, // do NOT show # of posts per cat
'title_li' => '', // include title list item
'current_category' => 1,
'depth' => 0 // levels deep to go down cat tree
);
$cats = get_the_category();
$current_cat = $cats[0];
$categories = get_categories($args);
?>
<nav>
<h4>Рубрики</h4>
<ul>
<?php foreach ( $categories as $category ) {
if ( $current_cat->cat_ID == $category->cat_ID ) {
echo '<li class="active">'.$category->name.'</li>';
}
else {
echo '<li><a href="'.get_category_link($category->term_id).'"'.'>'.$category->name.'</a></li>';
}
}; ?>
</ul>
</nav>