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 ?
$tax_term->count
should contain the number of posts in the category. You may need to add the$args
parameter if you want to include subcategory counts.Docs:
get_terms()
or simply :