Custom Post Type Category List & Post Count

I’m looking for Cutom Post Type Category List & Post Count. Here is my code..

            <?php
            $taxonomy = 'project-tags';
            $tax_terms = get_terms($taxonomy);
            ?>

            <?php
            foreach ($tax_terms as $tax_term) {
            echo '<li>' . '<a class="tag" href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $tax_term->name ) . '" ' . '><span class="tag_name">' . $tax_term->name.'</span><span class="tag_count">'. $show_count. '</span></a></li>';
            }?> 

This code works perfect for getting categories under my custom post type. But How do I get number of post count per category ?

Related posts

Leave a Reply

2 comments

  1. or simply :

    $args = array(
        'show_option_all'    => '',
        'orderby'            => 'name',
        'order'              => 'ASC',
        'style'              => 'list',
        'show_count'         => 1,
        'hide_empty'         => 0,
        'use_desc_for_title' => 1,
        'child_of'           => 0,
        'feed'               => '',
        'feed_type'          => '',
        'feed_image'         => '',
        'exclude'            => '',
        'exclude_tree'       => '',
        'include'            => '',
        'hierarchical'       => 1,
        'title_li'           => __( 'Categories' ),
        'show_option_none'   => __('No categories'),
        'number'             => null,
        'echo'               => 1,
        'depth'              => 0,
        'current_category'   => 0,
        'pad_counts'         => 0,
        'taxonomy'           => 'project-tags',
        'walker'             => null
    ); 
    
    wp_list_categories( $args );