wp_count_terms( string $taxonomy, array|string $args = array() )

Count how many terms are in Taxonomy.

Description Description

Default $args is ‘hide_empty’ which can be ‘hide_empty=true’ or array(‘hide_empty’ => true).

Parameters Parameters


(string) (Required) Taxonomy name.


(array|string) (Optional) Array of arguments that get passed to get_terms().

Default value: array()

Top ↑

Return Return

(array|int|WP_Error) Number of terms in that taxonomy or WP_Error if the taxonomy does not exist.

Top ↑

Source Source

File: wp-includes/taxonomy.php

function wp_count_terms( $taxonomy, $args = array() ) {
	$defaults = array('hide_empty' => false);
	$args = wp_parse_args($args, $defaults);

	// backward compatibility
	if ( isset($args['ignore_empty']) ) {
		$args['hide_empty'] = $args['ignore_empty'];

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

	return get_terms($taxonomy, $args);

Top ↑

Changelog Changelog

Version Description
2.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.