wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes
wp_count_terms › WordPress Function
Depuis2.3.0
Dépréciéen/a
› wp_count_terms ( $args = array(), $deprecated = '' )
| Paramètres: (2) |
|
| Retourne: |
|
| Défini(e) dans: |
|
| Codex: | |
| Changelog: |
|
Counts how many terms are in taxonomy.
Default $args is 'hide_empty' which can be 'hide_empty=true' or array('hide_empty' => true). {@internal The$deprecated parameter is parsed for backward compatibility only.}Fonctions en relation: wp_count_sites, count_users, wp_count_attachments, wp_count_comments, wp_count_posts
Source
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 = array_merge(
$args,
array( 'fields' => 'count' )
);
return get_terms( $args );
}