Viewing 2 replies - 1 through 2 (of 2 total)
  • <?php
    //display all categories that have at least one post, separate each category with comma+space, put each category in quotes
    $categories=get_categories();
    if ($categories) {
    $cat_count =count($categories);
    $output = '';
    foreach($categories as $category) {
        if ($category->count > 1) {
        $output .= '"<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>", ';
    }
    }
    }
    echo '<p>' . substr($output, 0, -2) . '</p>';  // display all but the last comma
    ?>
    Thread Starter djeff8593

    (@djeff8593)

    Thanks so much Michael. I’ll give it a go.

    Best – David

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘List Categories in an Array’ is closed to new replies.