function wp_count_terms( $taxonomy, $args = array() {}

Count how many terms are in Taxonomy.
Default $args is ‘hide_empty’ which can be ‘hide_empty=true’ or array(‘hide_empty’ => true).


  • string $taxonomy: Taxonomy name
  • array|string $args: Overwrite defaults. See get_terms()

Return values

returns:How many terms are in $taxonomy

Source code

function wp_count_terms( $taxonomy, $args = array() ) {

	$defaults = array('hide_empty' => false);

	$args = wp_parse_args($args, $defaults);

	// backwards compatibility

	if ( isset($args['ignore_empty']) ) {

		$args['hide_empty'] = $args['ignore_empty'];



	$args['fields'] = 'count';

	return get_terms($taxonomy, $args);



No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: