• Hi,

    I’ve developed my own theme and in my sidebar, I list the categories like this:

    <?php wp_list_categories('title_li=&show_count=1'); ?>

    I like that it shows the number of posts per category like this: Category (5), but I’d like to be able to customize just the number portion so that “(5)” is in a smaller font than the Category.

    How do I extract just the “show_count” so I can change its appearance?

    THANKS!!!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    replace <?php wp_list_categories('title_li=&show_count=1'); ?>
    with this:

    <?php
    $variable = wp_list_categories('echo=0&show_count=1&title_li=');
    $variable = str_replace(array('(',')'), array('(<span class="cat-count">','</span>)'), $variable);
    echo $variable;
    ?>

    and put this in your stylesheet

    .cat-count{
    font-size: 12px;
    }

    And change the font-size to your liking.

    Moderator keesiemeijer

    (@keesiemeijer)

    Oops that only changes the font size of the numbers. to change the whole “(5)” use this:

    <?php
    $variable = wp_list_categories('echo=0&show_count=1&title_li=<h2>Categories</h2>');
    $variable = str_replace(array('(',')'), array('<span class="cat-count">(',')</span>'), $variable);
    echo $variable;
    ?>

    Thread Starter gbai

    (@gbai)

    thank you very much!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘formatting "number of posts per category"’ is closed to new replies.