Posted By

JoshChris on 07/14/13


Tagged

wordpress widget functionsphp


Versions (?)

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


 / Published in: PHP
 

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

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

  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. }?>

Report this snippet  

You need to login to post a comment.