views:

64

answers:

1

Hello!

How could I include the count of posts under a category into the a-tag when listing categories. This has been a problem for me many times but now I decided to find out.

<li><a href="#" title="asd">php</a> (1)</li>

to

<li><a href="#" title="asd">php (1)</a></li>

Is you propably assumed, I'm using wp_list_categories to make this list.

Any solutions?

Martti Laine

A: 

I solved it. Posting here so someone can use it :)

<?php
$data = wp_list_categories('show_count=1&echo=0');
$data = preg_replace('/\<\/a\> \((.*)\)/',' ($1)</a>',$data);
echo $data;
?>
Martti Laine