Skip to content

Instantly share code, notes, and snippets.

@susanlangenes
Created January 8, 2016 02:12
Show Gist options
  • Save susanlangenes/e53d173a08c51a33682f to your computer and use it in GitHub Desktop.
Save susanlangenes/e53d173a08c51a33682f to your computer and use it in GitHub Desktop.
Display post count for a taxonomy term. Nice for archive templates.
<?php
// this will output like so: Taxonomy Term Name (19) <- where '19' is the number of posts with that taxo term.
?>
<h1 class="page-title">
<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); echo $term->name; ?>
&nbsp;(<?php global $wp_query;
echo $wp_query->found_posts; ?>)
</h1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment