Move the posts count inside the link of the Archive and Category widgets of WordPress
<?php /* This code filters the Categories archive widget to include the post count inside the link */ | |
add_filter('wp_list_categories', 'cat_count_span'); | |
function cat_count_span($links) { | |
$links = str_replace('</a> (', ' (', $links); | |
$links = str_replace(')', ')</a>', $links); | |
return $links; | |
} | |
/* This code filters the Archive widget to include the post count inside the link */ | |
add_filter('get_archives_link', 'archive_count_span'); | |
function archive_count_span($links) { | |
$links = str_replace('</a> (', ' (', $links); | |
$links = str_replace(')', ')</a>', $links); | |
return $links; | |
}?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Whoa... That's pretty nice. Thanks for this! I did have to do some tweaking though.
I actually had some categories that had the "(" category string and this fixed that.
BTW, I was linked here from http://snipplr.com/view/71843/move-the-posts-count-inside-the-link-of-the-archive-and-category-widgets-of-wordpress/