• Hi, please! Someone help me with this: How style category counts, for example: Category1 (33) I want to add “span” for counts: “(33)” and align to right.

    my code:

    <?php
    // Grab the categories - top level only (depth=1)
    $get_cats = wp_list_categories( 'echo=0&show_count=1&title_li=&depth=1&hide_empty=0' );
    
    //  Remove Parentheses from Category Counts
    $get_cats = preg_replace('~\((\d+)\)(?=\s*+<)~', '$1', $get_cats);
    
    // Split into array items
    $cat_array = explode('',$get_cats);
    
    // Amount of categories (count of items in array)
    $results_total = count($cat_array);
    
    // How many categories to show per list (round up total divided by 3)
    $cats_per_list = ceil($results_total / 2);
    
    // Counter number for tagging onto each list
    $list_number = 1;
    
    // Set the category result counter to zero
    $result_number = 0;
    ?>

The topic ‘Style Category counts’ is closed to new replies.