Backlighting the current heading

The code below displays all the existing headings and can be added to any place in the template, for example in the sidebar. Its peculiarity is that it adds to the category that is currently open, the css class active, with which you can make its highlight in the menu.

 <?php $catname = single_cat_title( '' , 0); $args = array('hide_empty' => '0','orderby' => 'ID');
      $categories = get_categories($args);

      foreach($categories as $category) {
      if ($catname == $category->name) { 
          $class="category active"; 
      } else {

echo '<a href="' . get_category_link( $category->term_id ) . '" class="'.$class.'">'.$category->name.'</a>';

Further, in our css file, you can add any code to highlight the current heading, for example, make it red:

.active { color: red; }

Требуется подобная доработка? Напишите нам.