• Hi, I have a function here to add a class name to the_category output, but it adds the same name to all links. How can i change ‘custom-slug’ to the slug for the category, so i can style each link individually?

    function add_class_to_category( $thelist, $separator, $parents){
        $class_to_add = 'custom-slug';
        return str_replace('<a href="',  '<a class="'. $class_to_add. '" href="', $thelist);
    }
    
    add_filter('the_category', __NAMESPACE__ . '\\add_class_to_category',10,3);
  • The topic ‘how to add class name to the_category output’ is closed to new replies.