jmccole83
5/23/2018 - 10:04 AM

List all the Categories on a site

Add the below snippet to output a list of categories to template, update the terms for custom taxonomies.

$terms = get_terms("category");
 $count = count($terms);
 if ( $count > 0 ){
     echo "<ul>";
     foreach ( $terms as $term ) {
       echo "<li><a href=". get_home_url() . '/category/' . $term->slug .">" . $term->name . "<a/></li>";

     }
     echo "</ul>";
 }