• When I insert the Archives widget and check the “Show Post Counts”, it wraps the number in parentheses. Is there any way to edit that within functions.php without modifying the core files? Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • st3vi3

    (@st3vi3)

    would love to know this too – i have searched and search

    i managed to do this with the wp_categories_list in my child theme as follows:

    // remove parentheses from category list and add span class to post count
    function categories_postcount_filter ($variable) {
    $variable = str_replace('(', '<span class="post-count"> ', $variable);
    $variable = str_replace(')', ' </span>', $variable);
       return $variable;
    }
    add_filter('wp_list_categories','categories_postcount_filter');

    alas replacing wp_list_categories with wp_get_archives has no impact.

    Anyone any ideas?

    Michael

    (@alchymyth)

    archives are a bit different:

    add_filter('get_archives_link', 'archive_count_no_brackets');
    function archive_count_no_brackets($links) {
    $links = str_replace('</a>&nbsp;(', '</a>&nbsp;', $links);
    $links = str_replace(')', '', $links);
    return $links;
    }
    st3vi3

    (@st3vi3)

    alchymyth
    THANK YOU SO MUCH!

    hmmm *wonders why it is $links and not $variable*
    – how does one know what parameter to pick?!

    php nube here ??

    Michael

    (@alchymyth)

    hmmm *wonders why it is $links and not $variable*
    – how does one know what parameter to pick?!

    you can make one up – as long as it does not conflict with one of the global variables used by the core of wordpress ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Remove Post Count Parentheses From Widget’ is closed to new replies.