How to display custom taxonomy list in wordpress

I had some trouble with showing the list of categories on the main page of this blog. At first, I thought that there are some good plugins that will do all, but I wasn’t able to find a good one.

After all, I decided to customize my WordPress blog by implementing the following code and by giving some good flavour by adding some CSS. I’ve written some comments in the following code so you can just check it out!


// custom taxonomy name
$taxo = 'pc_games';

// You can just add some parameter

$args = array('pad_counts' => true,'hide_empty' => false);

// Getting your custom terms as a list
$terms = get_terms( $taxo , $args );

if ( count( $terms ) != 0 ) {
    echo '
    '; // Loop the terms to display it in the li foreach ( $terms as $term ) { // Get the url from the list of terms $term = sanitize_term( $term, $taxo ); $term_link = get_term_link( $term, $taxo ); if ( is_wp_error( $term_link ) ) { continue;} echo '
  • '; echo '' . $term->name . '(' . $term->count . ')'; echo '
  • '; } echo '
'; }

The above code has been tested in WordPress version 3.8.1 and above.