WordPress.org

Ready to get started?Download WordPress

Forums

Remove brackets around cat post count? (9 posts)

  1. planetphillip
    Member
    Posted 9 years ago #

    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.

    TIA
    Phillip

  2. Kafkaesqui

    Posted 9 years ago #

    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.

  3. planetphillip
    Member
    Posted 9 years ago #

    Worked like a dream. Thank you.

  4. alexc
    Member
    Posted 9 years ago #

    Hi,

    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.

    Thanks,

    Alex

  5. jfriesen
    Member
    Posted 9 years ago #

  6. prissed
    Member
    Posted 9 years ago #

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

    Edit: Damn, I must type slow. :P

  7. Kafkaesqui

    Posted 9 years ago #

    @alexc
    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).

  8. alexc
    Member
    Posted 9 years ago #

    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)

    Cheers,

    Alex

  9. matthewr85
    Member
    Posted 9 years ago #

    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).

Topic Closed

This topic has been closed to new replies.

About this Topic