Skip to content

Instantly share code, notes, and snippets.

@blainerobison
Last active December 17, 2015 22:35
Show Gist options
  • Save blainerobison/1f1e59c99f5c9a78b93d to your computer and use it in GitHub Desktop.
Save blainerobison/1f1e59c99f5c9a78b93d to your computer and use it in GitHub Desktop.
wp: Move Category Count Inside Link [WordPress]
/**
* 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>&nbsp;(', ' <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