Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_count_terms ›

Seit2.3.0
Veraltetn/v
wp_count_terms ( $taxonomy, $args = array() )
Parameter: (2)
  • (string) $taxonomy Taxonomy name.
    Erforderlich: Ja
  • (array|string) $args Optional. Array of arguments that get passed to get_terms(). Default empty array.
    Erforderlich: Nein
    Standard: array()
Gibt zurück:
  • (array|int|WP_Error) Number of terms in that taxonomy or WP_Error if the taxonomy does not exist.
Definiert in:
Codex:

Count how many terms are in Taxonomy.

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



Quellcode

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'];
		unset( $args['ignore_empty'] );
	}

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

	return get_terms( $taxonomy, $args );
}