Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is it possible using wp_list_categories set count of post in category in the href?

share|improve this question
1  
It's possible, with some regular expression jiggery pokery. Some variation on this –  vancoder Apr 11 '13 at 18:59
    
+1 for jiggery pokery –  Eric Holmes Jan 31 at 20:13

1 Answer 1

Regular expression jiggery pokery identified:

<?php
$categories = wp_list_categories('title_li=&show_count=1&echo=0');
$categories = preg_replace('/<\/a> \(([0-9]+)\)/', ' <span class="count">[\\1]</span></a>', $categories);
echo $categories;
?>
share|improve this answer
2  
nice solution @vancoder, but preg_replace might be a better choice because ereg_replace is deprecated since php 5.3, according to php.net/ereg_replace. –  birgire Apr 11 '13 at 19:45
    
@birgire Excellent point, answer updated. –  vancoder Apr 11 '13 at 20:47
    
Great solution thanks. –  Murhaf Sousli Jul 13 at 1:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.