WordPress at a glance

wp_count_terms() WP 1.0

Count how many terms are in Taxonomy.

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

Works based on: get_terms()
✈ 1 time = 0.000664s = slow | 50000 times = 26s = slow

No Hooks.


Array/Int/WP_Error. Number of terms in that taxonomy or WP_Error if the taxonomy does not exist.


wp_count_terms( $taxonomy, $args );
$taxonomy(string) (required)
Taxonomy name.
Array of arguments that get passed to get_terms().
Default: empty array

Code of wp count terms: wp-includes/taxonomy.php VER 5.0.3

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);

Related Functions

From tag: counts (counting of any)

More from category: Any taxonomy

No comments
    Hello, !     Log In . Register