Stop the display of the count of listings for sub categories

Hi,
when styling the sub category links, the counts appear outside of the styled link (it needs display:block which is causing this as the count for some reason is not part of the link). Ideally I want the counts as part of the links so they can be inline within the block link.

Is that possible? I've searched google and found nothing to help with this. So I decided to just uncheck the show count box in the settings but the counts still show?

Please can anyone help ideally get the counts working as part of the main link so on the same line or failing that why is the setting to stop showing the counts not working?

This is what I have currently:

--- LINK ---
(1)
--- LINK ---
(3)
--- LINK ---
(9)

I want something like this ideally:

--- LINK (1) ---

  • Tyler Postle
    • CGO

    Hey Jon,

    Hope you're doing well today! Apologies for the delay here.

    Ari has recently moved and is still waiting on getting his internet back.

    In the meantime, I would be more than happy to help out here!

    If you want to privately send access, then you can do so through our contact form: https://premium.wpmudev.org/contact/

    Send in:

    Subject: "Attn: Tyler Postle"
    site access:
    admin access(optional: just in-case):
    login link:
    relevant urls:

    Select "I have a different question" for your topic - this ensures that it gets assigned to me :slight_smile:

    Look forward to hearing from you Jon!

    Cheers,
    Tyler

  • Tyler Postle
    • CGO

    Hey Jon,

    Awesome, I got them, thanks for sending that :slight_smile:

    First off, wow, I live on Vancouver Island! What are the chances...

    Okay, so I went into the template and made a little edit here so we can get your post count inside your link. I've attached the updated file (template-tags.php) and you can just overwrite the original here: /wp-content/plugins/directory/core/

    I'll also post the edit I made here, in-case you ever need to add it again :slight_smile: ie. when you update the plugin.

    Find this line at approx. 459:

    $output .= '<a href="' . get_term_link( $category ) . '" title="' . sprintf( __( 'View all posts in %s', DR_TEXT_DOMAIN ), $category->name ) . '" >' . $category->name . '</a> (' . $category->count . ') <br />';

    and swap it with this version:

    $output .= '<a href="' . get_term_link( $category ) . '" title="' . sprintf( __( 'View all posts in %s', DR_TEXT_DOMAIN ), $category->name ) . '" >' . $category->name . '' . $category->count . '</a> <br />';

    The only change is at the end where we throw the category count inside the a tag :slight_smile:

    Hope that helps Jon!

    Cheers,
    Tyler

    PS. Had to zip up the file before attaching it, so just unzip it and copy over the .php file.

  • Jon
    • Site Builder, Child of Zeus

    That works great thanks! I just made a slight change to put the count in brackets with a space after the category name as it was displaying like this:

    accommodation2

    $output .= '<a href="' . get_term_link( $category ) . '" title="' . sprintf( __( 'View all posts in %s', DR_TEXT_DOMAIN ), $category->name ) . '" >' . $category->name . ' (' . $category->count . ') </a><br />';

    I have come across this issue on other wordpress sites with different plugins, support threads and I think possibly with the wordpress core too. Seems odd, surely it would be better just to have the count within the link to start with? I can't see any real reason for it not to be?

    Thanks for the fix :slight_smile:

  • Tyler Postle
    • CGO

    Hey Jon!

    Oops, good stuff adding in the brackets there :slight_smile: I missed that.

    Yeah, I'm not really sure on the logic behind that either.

    Wouldn't mind living on Vancouver Island myself! I have visited loads and will continue to do so. Got lots of friends in Victoria.

    I live in Victoria! haha that's crazy.

    Have a great weekend Jon.

    Cheers,
    Tyler

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.