WordPress.org

Ready to get started?Download WordPress

Forums

Category Count INSIDE Category List? (7 posts)

  1. badlydrawnbrian
    Member
    Posted 7 years ago #

    Hi,

    I'm just customising the templates and I've made a horizontal list of categories. Each category has a category count in brackets next to it. Fairly simple, However....

    I wanted to make each item a "button" as such by changing the styling to span the whole column and add in top and bottom padding. I then set the list "li a" style to "display: block" to make it all clickable as a link (not just the text).

    The only trouble with this is that because the list count (in brackets) does not appear to be included in the list element

  2. it throws this onto the next line and outside the "button" effect I'm aiming for.

    What I'm trying to do is do find a way to place the count (1) inside the list element so that it all displays on one line.

    Hope that makes sense and hope someone can help me out there. It seems strange that's its generated outside the list in the first place.

    Many thanks

  • gspark
    Member
    Posted 7 years ago #

    anyone figure this out yet ? I have 10,000 for the person who does

  • Sivar
    Member
    Posted 7 years ago #

    There you go! I prefer cash. ;)

  • gspark
    Member
    Posted 6 years ago #

    I found a workable solution in classes.php

    if ( isset($show_count) && $show_count )
    $link .= '<span>(' . intval($category->category_count) . ')</span>';

    this puts a < span > tag around the count then for CSS i used this

    position: relative;
    float: right;
    top: ;
    left: ;

    I liked my suggestion better so guess that awards me the 10,000 :))

  • Sivar
    Member
    Posted 6 years ago #

    I guess, it depends on if you like to have the number in the link or not. But your idea is certainly worth 1/10 of that reward :D.

  • mikecicc
    Member
    Posted 6 years ago #

    gspark, I think i need your help with this...I've tried these instructions, and yours but i cant get the post counts to display next to the category, instead they display below the category...

    your instructions are kind of difficult to follow, where should I put that script you suggested, and what should I name the element in my CSS class that should feature those characteristics?

  • erick_paper
    Member
    Posted 6 years ago #

    Hi, I would like to show the count of only the current category being displayed in the category archive listing. How to do this without mucking about with WordPress code which will get rewritten next time there's an update?

    Thanks!

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags