Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_count_terms [ WordPress Function ]

wp_count_terms ( $taxonomy, $args = array() )
Parameters:
  • (string) $taxonomy Taxonomy name
  • (array|string) $args Overwrite defaults. See get_terms()
Uses:
Returns:
  • (int) How many terms are in $taxonomy
Defined at:



Count how many terms are in Taxonomy.

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

Source


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

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

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

    return 
get_terms($taxonomy$args);
}
?>

Examples [ wp-snippets.com ]

Top Google Search Results

More ...

User discussions [ wordpress.org ]

0 User Note(s)

None yet. Be the first!

Add New ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics