Function Reference: geodir_get_terms_count

Summary

Retrieve terms count for given post type.

Package

GeoDirectory

Parameters

$post_type
(string) (required) Post type.

Default: None

Return Values

(int)
  • Total terms count.

Change Log

Since: 1.4.6

Source File

geodir_get_terms_count() is located in geodirectory-admin/admin_functions.php [Line: 5570]

Source Code

function geodir_get_terms_count( $post_type ) {
    $args = array( 'hide_empty' => 0 );

    remove_all_filters( 'get_terms' );

    $taxonomy = $post_type . 'category';

    // WPML
    $is_wpml = geodir_is_wpml();
    $active_lang = 'all';
    if ( $is_wpml ) {
        global $sitepress;
        $active_lang = $sitepress->get_current_language();
        
        if ( $active_lang != 'all' ) {
            $sitepress->switch_lang( 'all', true );
        }
    }
    // WPML
            
    $count_terms = wp_count_terms( $taxonomy, $args );

    // WPML
    if ( $is_wpml && $active_lang !== 'all' ) {
        global $sitepress;
        $sitepress->switch_lang( $active_lang, true );
    }
    // WPML
    $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
     
    return $count_terms;
}