Support » Fixing WordPress » Remove brackets around cat post count?

  • Hi,
    Is it possible to either remove or replace the brackets around the category post counts?

    I thought I did this in WP 1.2 but I might be thinking back even further when I was using MT.


Viewing 8 replies - 1 through 8 (of 8 total)
  • If this is for list_cats (or wp_list_cats), then you can only change them by editing the source, since they’re hardcoded.

    In wp-includes/template-functions-category.php near the end of the file (line 243 in 1.5.1), look for this code black (line 348 in 1.5.1):

    if (intval($optioncount) == 1) {
    $link .= ' ('.intval($category_posts["$category->cat_ID"]).')';

    Just modify ‘ (‘ and ‘)’ in the $link string.

    When editing source code, backup up any files you’re working on, and comment your changes for future reference.

    Worked like a dream. Thank you.


    Didn’t want to start another thread to ask this – is there anyway to remove the post count completely? I tried modifying the code but kept getting errors.

    Managed to work around it by setting ‘if (intval($optioncount) == 1)’ to ‘if (intval($optioncount) == 0)’, but I’d prefer to remove it if possible.



    Just change the call in your theme template:
    wp_list_cats() and/or list_cats()

    Edit: Damn, I must type slow. 😛

    Just follow the links above and check the info on the ‘optioncount’ parameter. You’re probably setting this in your template tag (since it’s off by default).

    I changed the template-functions-category.php back to normal and turned off optioncount in the theme. Works perfectly now, thanks for that! (Promise I’ll check the Wiki next time – ended up ignoring it because the text was scrambled in Safari, time to use Firefox methinks)



    It might be a good idea to enable a GUI interface to change these settings in Admin CP.

    This is a beautiful piece of “software”, and I’m sure many would rather be able to know their modifications will work, rather than risk losing it all (assuming they dont backup).

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Remove brackets around cat post count?’ is closed to new replies.