Forums

Entry / Entries After Category Count (3 posts)

  1. norbiu
    Member
    Posted 2 years ago #

    I want to add 'entry / entries' after each category count. Here's what I've got up until now:

    $catID = get_cat_id('Projects');
    $variable = wp_list_categories('title_li=&echo=0&show_count=1&exclude=' . $catID);
    $variable = str_replace( '(', '', $variable);
    $variable = str_replace( ')', ' entries', $variable);
    echo $variable;

    How can I make the code detect categories with 1 entry and echo "entry" instead of "entries"?

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    How about:

    $catID = get_cat_id('Projects');
    $test = get_categories('exclude=' . $catID);
    if(count($test) >= 2) $extra = 'entries';
    else $extra = 'entry';
    $variable = wp_list_categories('title_li=&echo=0&show_count=1&exclude=' . $catID);
    $variable = str_replace( '(', '', $variable);
    $variable = str_replace( ')', $extra, $variable);
    echo $variable;
  3. norbiu
    Member
    Posted 2 years ago #

    Doesn't seem to work. The count is always showing 3.

Topic Closed

This topic has been closed to new replies.

About this Topic