Move the posts count inside the link of the Archive and Category widgets of WordPress


/ Published in: PHP
Save to your folder(s)

Genius stuff right here from https://gist.github.com/BronsonQuick


Copy this code and paste it in your HTML
  1. <?php /* This code filters the Categories archive widget to include the post count inside the link */
  2. add_filter('wp_list_categories', 'cat_count_span');
  3. function cat_count_span($links) {
  4. $links = str_replace('</a> (', ' (', $links);
  5. $links = str_replace(')', ')</a>', $links);
  6. return $links;
  7. }
  8. /* This code filters the Archive widget to include the post count inside the link */
  9. add_filter('get_archives_link', 'archive_count_span');
  10. function archive_count_span($links) {
  11. $links = str_replace('</a>&nbsp;(', ' (', $links);
  12. $links = str_replace(')', ')</a>', $links);
  13. return $links;
  14. }?>

URL: https://gist.github.com/BronsonQuick/2692275

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.