Remove parentheses from post count in parent category
-
I’ve hunted all over the forums, but I can’t find the answer to this.
I have an archives page styled to show the post counts for each category. I’m using the code found in the codex to remove the parentheses from the post count.
I’m wrapping the post count in a span tag to style it. Works fine for all the child categories, but the parent categories are displaying the post count without the span wrap and with the parentheses.
Here’s the code as I have it in the template:
<?php $variable = wp_list_categories( 'echo=0&show_count=1&title_li=' ); $variable = preg_replace( '~\((\d+)\)(?=\s*+<)~', '<span>$1</span>', $variable ); echo $variable; ?>
Help is greatly appreciated!
- The topic ‘Remove parentheses from post count in parent category’ is closed to new replies.