Paint the active category with a different color

Rate this post

I have a taxonomy-blogs_taxanomy.php file. Inside the file, I display the category names and also go to them by reference. Now I need to make sure that the active category in which I am is closed with some color. Please help.

    $terms = get_terms( 'blogs_taxanomy', array(
        'hide_empty' => false,
        'taxonomy' => 'blogs_taxanomy',
        ) );  

foreach ( $terms as $term ) {   
    <div class="blog-container-control center" >
            <div class="col-12 pt-2 pb-2 blog-container-inner-control">
                    <a  href="<?php echo get_term_link( $term ); ?>"><span class="link"><?php echo 
                    $term->name; ?></span><a>

I need the link of the category I am currently on the page to be filled in.



I use this and this work.

$categories = get_queried_object();
$category_name = $categories->name;
$cat_name =  $term->name;
 if( $category_id == $cat_name) { ?>
   <div class="col-lg-4 active">

Leave a Reply

Your email address will not be published.

Back to top button