Last active
December 17, 2015 22:35
-
-
Save blainerobison/1f1e59c99f5c9a78b93d to your computer and use it in GitHub Desktop.
wp: Move Category Count Inside Link [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
/** | |
* Move Category Post Counts Inside Link | |
* | |
* filters wp_list_categories() | |
* | |
* @param string $links link html output | |
* @return string | |
*/ | |
function prefix_move_category_count( $links ) { | |
$links = str_replace( '</a> <span class="count">', ' <span class="count">', $links ); | |
$links = str_replace( '</span>', '</span></a>', $links ); | |
return $links; | |
} | |
add_filter( 'wp_list_categories', 'prefix_move_category_count' ); | |
/** | |
* Move Archive Post Counts Inside Link | |
* | |
* filters get_archives_link() | |
* | |
* @param string $links link html output | |
* @return string | |
*/ | |
function prefix_move_archive_count($links) { | |
$links = str_replace( '</a> (', ' <span class="count">(', $links ); | |
$links = str_replace( ')', ')</span></a>', $links ); | |
return $links; | |
} | |
add_filter( 'get_archives_link', 'prefix_move_archive_count' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment