WordPress.org

Forums

Additional Styling to Category List (11 posts)

  1. justinshattuck
    Member
    Posted 8 years ago #

    I'm currently using <?php wp_list_categories('orderby=name&show_count=1&hierarchical=0&title_li='); ?> to output my categories list into my sidebar. I'm wanting to modify the style slightly so that when the list of cats is outputted into each <li></li> the total number of posts within that category is outputted next to it. It seems that the count is outside of the <a></a> block element during output. I've been searching through the codex, support forums and even looked into hacking up the function that is outputting the code itself and I cannot find a resolution.

    Currently the output is as such:

    CategoryA
    (2)
    CategoryB
    (9)
    CategoryC
    (19)

    and I want it to appear as:
    CategoryA (2)
    CategoryB (9)
    CategoryC (19)

    so on and so forth, I checked into my style, tried everything I can think of .. any assistance is appreciated.

  2. moshu
    Member
    Posted 8 years ago #

    It seems that the count is outside of the block

    It should - and to change that you would need to modify core files.

    What you describe is a simple CSS issue but I couldn't check it on the site linked to your profile.

  3. justinshattuck
    Member
    Posted 8 years ago #

    moshu: Which core file(s) would I have to modify to place it within the block?

  4. matte2k
    Member
    Posted 7 years ago #

    moshu.. can u look at my site
    http://www.seriegrossisten.se/blogg/

    got the same problem.. tried and tried to edit the css but can't get it to work....

    please....

  5. gspark
    Member
    Posted 7 years ago #

    The question one has to ask is why is the count placed outside of the link, this is maddness ? One wonders if anyone notices these little things when developing wordpress, the most simplest things are often overlooked, can I get a fraken spoon with my bowl of soup * grin *

  6. Root
    Member
    Posted 7 years ago #

    OT. Is there a good reason why the total needs to be in a link?

  7. gspark
    Member
    Posted 7 years ago #

    doh! was thinking that myself :) even still, show count within the < li > never lines up anyway which is surpising

  8. Root
    Member
    Posted 7 years ago #

    It is inteesting. The number is just hanging there in space. It is uncontained text (no markup). One of my pet hates. Hacking is needed.

  9. insteletr
    Member
    Posted 7 years ago #

    Hey there, i got the same problem in my blog. Doea anyone knows how to solve it?

    Thx!

  10. Sivar
    Member
    Posted 7 years ago #

    For the count-in-the-link-issue, here's the solution.

    OT. Is there a good reason why the total needs to be in a link?
    Yes. If you use display:block for the links (i.e. to get a nice hover which styles the entire line), a seperate line for the post-count is very annoying. I was really surprised to see that wp_list_categories (resp. walker_category) doesn't include it in the link by default.

  11. gspark
    Member
    Posted 7 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: ;

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.