[resolved] Add a class on an li for "current category" (2 posts)

  1. Noel Forte
    Posted 2 years ago #

    Currently I'm using this code to display a string of breadcrumbs ( Link / Link / Link) across the top of my archive pages.

    	$cat_arguments = array(
    	  'orderby' => 'name',
    	  'parent' => 0
    	$cats = get_categories($cat_arguments);
    	$i = 0;
    	foreach($cats as $category) {
    		echo '<li><a href="'.get_category_link( $category->term_id ).'">'.$category->name.'</a>';
    		if ($i < count($cats)) {
    			echo '<span class="divider">/</span></li>';

    However, I want to add a class to the li that contains the name of the currently displaying category. What's the best way to do this?

  2. Noel Forte
    Posted 2 years ago #

    UPDATE: I was able to figure this out, thanks to some conditional tags.

Topic Closed

This topic has been closed to new replies.

About this Topic