Highlighting current category using get_categories and postprocessing the result
-
Hello,
I would like to highlight the current category as if I were using wp_list_categories(); (which displays a “current-cat” class).
But I just can’t use wp_list_categories as I am changing the result given by get_categories thanks to its array form.
Here is the code :
<?php $catID_Concours = get_cat_ID("concours"); $catID_Fini = get_cat_ID("fini"); $excludeCatID = $catID_Concours . ',' . $catID_Fini; $args = array( 'exclude' => $excludeCatID, /* On retire la catégorie Concours du menu */ 'title_li' => '0', 'hide_empty' => '1', ); $categories = get_categories($args); $menu = ''; foreach($categories as $category) { $category_link = get_category_link( $category ); $menu .= '<li class="cat-item '. $category->slug .'"><a href="'. $category_link .'">'. $category->name .'</a></li>'; } echo $menu; ?>
So, is there a way to add a current category function to this code?
Séane
- The topic ‘Highlighting current category using get_categories and postprocessing the result’ is closed to new replies.