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.

I'm using this code:

$args = array(
            'hide_empty' => FALSE,
            'title_li'=> __( '' ),
            'show_count'=> 1,
        );
        wp_list_categories($args);

How can i wrap the post count in a span for further styling?

Thanks

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

adding a filter to functions.php of your theme is one possibility:

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

this would add the spans to any occurrence of 'wp_list_categories()' site wide.

or change your code into:

$args = array(                 
  'hide_empty' => FALSE,                 
  'title_li'=> __( '' ),                 
  'show_count'=> 1,             
  'echo' => 0
);             
  $links = wp_list_categories($args);
  $links = str_replace('</a> (', '</a> <span>(', $links);
  $links = str_replace(')', ')</span>', $links);
echo $links;
share|improve this answer
    
Thanks! used the second one –  benhowdle89 May 15 '11 at 22:29
add comment

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.