WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can this be achived?

Replace the post count on wp_list_categories with "Has Posts" instead of number and "No Posts" if none.

share|improve this question
up vote 1 down vote accepted

Add the below in your theme's functions.php. It should work the way you want

function my_list_categories( $output, $args ) {
    $output = str_replace( '(0)', '(No Posts)', $output );
    $output = preg_replace( '/\((\d+)\)/', '(Has Posts)', $output );
    return $output;
add_filter( 'wp_list_categories', 'my_list_categories', 10, 2 );
share|improve this answer
This replaced the post number, but it also changed the post category name. I need it to only replace the "(12)" for example – Shae Oct 1 '13 at 15:34
I have improved the answer, please check. Now it should be fine – Maruti Mohanty Oct 1 '13 at 16:01

Your Answer


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.