Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Move the posts count inside the link of the Archive and Category widgets of WordPress
Copy link

Dilden commented Sep 12, 2014

Whoa... That's pretty nice. Thanks for this! I did have to do some tweaking though.

add_filter('wp_list_categories', 'cat_count_span');
function cat_count_span($links) {
    $links = str_replace('</a>', '', $links);
    $links = str_replace('</li>', '</a></li>', $links);
    return $links;

I actually had some categories that had the "(" category string and this fixed that.

BTW, I was linked here from

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment