Created
May 14, 2012 06:45
-
-
Save BronsonQuick/2692275 to your computer and use it in GitHub Desktop.
Move the posts count inside the link of the Archive and Category widgets of WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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
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/