Forums

[resolved] Adding postcontent to category count (4 posts)

  1. matthewpaul
    Member
    Posted 3 years ago #

    I'm using wp_list_categories to display my categories with a count next to each category. I removed the parentheses from the category counts. How do I add the word "entries" after each count number? The code below is what I have currently.

    <?php
    $variable = wp_list_categories('title_li=&echo=0&show_count=1');
    $variable = str_replace(array('(',')'), '', $variable);
    echo $variable;
    ?>

    Below is an example of what I want this to look like:
    Category-1 2 entries
    Category-2 5 entries
    Category-3 4 entries

    Help is appreciated.

  2. Michael Fields
    Theme Wrangler
    Posted 3 years ago #

    Not tested, but it should work :)

    <?php
    $variable = wp_list_categories('title_li=&echo=0&show_count=1');
    $variable = str_replace( '(', '', $variable);
    $variable = str_replace( ')', ' entries', $variable);
    echo $variable;
    ?>

  3. matthewpaul
    Member
    Posted 3 years ago #

    Perfect, thanks!

  4. Michael Fields
    Theme Wrangler
    Posted 3 years ago #

    No problem!

Topic Closed

This topic has been closed to new replies.

About this Topic