wp_count_terms() – Count how many terms are in Taxonomy.
You appear to be a bot. Output may be restricted
Description
Counts how many terms are in taxonomy.
Default $args is 'hide_empty' which can be 'hide_empty=true' or array('hide_empty' => true).
Usage
$string|WP_Error = wp_count_terms( $args, $deprecated );
Parameters
- $args
- ( array|string ) optional – Optional. Array or string of arguments. See WP_Term_Query::__construct() for information on accepted arguments. Default empty array.
- $deprecated
- ( array|string ) optional – Optional. Argument array, when using the legacy function parameter format. If present, this parameter will be interpreted as `$args`, and the first function parameter will be parsed as a taxonomy or array of taxonomies. Default empty.
Returns
string|WP_Error Numeric string containing the number of terms in that taxonomy or WP_Error if the taxonomy does not exist.
Source
File name: wordpress/wp-includes/taxonomy.php
Lines:
1 to 30 of 30
function wp_count_terms( $args = array(), $deprecated = '' ) { $use_legacy_args = false; // Check whether function is used with legacy signature: `$taxonomy` and `$args`. if ( $args && ( is_string( $args ) && taxonomy_exists( $args ) || is_array( $args ) && wp_is_numeric_array( $args ) ) ) { $use_legacy_args = true; } $defaults = array( 'hide_empty' => false ); if ( $use_legacy_args ) { $defaults['taxonomy'] = $args; $args = $deprecated; } $args = wp_parse_args( $args, $defaults ); // Backward compatibility. if ( isset( $args['ignore_empty'] ) ) { $args['hide_empty'] = $args['ignore_empty']; unset( $args['ignore_empty'] ); } $args['fields'] = 'count'; return get_terms( $args ); }