Add HTML Attributes To Anchor Tags In `wp_list_categories()` Function


I’m using the wp_list_categories() function which generates an unordered list with list items and anchor tags for the categories. Is there any way to add HTML attributes to the <a> tags which hold the category links?

I’d like to add a title attribute which is the same as the category, and a class attribute, but looking at the docs, in the list of associative array properties I can’t see how to do this?

The code I’m using is:

    echo '<ul class="cat-sidebar-list">';
        $args_list = array(
        'taxonomy' => 'news_categories',
        'show_count' => false,
        'hierarchical' => true,
        'hide_empty' => false,
        'title_li' => '',
        echo wp_list_categories($args_list);
    echo '</ul>';

Thanks in advance for any help.

, , , The Chewy 2 years 2020-09-04T20:10:19-05:00 0 Answers 88 views 0

Leave an answer