Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

hjmatt on "Post Counts On One Line For Categories Widget With Span"

$
0
0

Hi,

I can see this question has been asked many times before, but what I want is a variation on code that I know works.

Over here there is a solution to get the posts counts next to the category titles in the default categories widget.

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

What I would like is a variation on that solution to incorperate a span class for positioning purposes. In terms of HTML/CSS. I need the output the same as this one for woocommerce product category listing:

<li class="cat-item cat-item-24">
<a href="http://domain.com/product-category/cleaning/">Cleaning</a>
<span class="count">(0)</span>
</li>

It's that <span class="count"> that I need.

Regards,
Matt


Viewing all articles
Browse latest Browse all 8245

Trending Articles