Forums

[resolved] Change html output in categories widget (3 posts)

  1. yochi
    Member
    Posted 1 year ago #

    Hi

    I have been googeling all day now, trying to find a solution to my problem.

    I want to modify the output of my Categories widget so that it puts a span class or something around the post count, so i can style it the way i want.

    Does anyone have a suggestion how i can do this?

    yochi

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    try to add a filter function to functions.php of your theme;
    for instance:

    add_filter('wp_list_categories', 'add_span_cat_count');
    function add_span_cat_count($links) {
    $links = str_replace('</a> (', '</a> <span>(', $links);
    $links = str_replace(')', ')</span>', $links);
    return $links;
    }

    if you need a css class on the span, add it here in the above:
    <span>
    for instance:
    <span class="cat-count">

  3. yochi
    Member
    Posted 1 year ago #

    Thank you very much. That worked:)

Topic Closed

This topic has been closed to new replies.

About this Topic