Exclude post with taxonomy and from the terms (taxonomy & tag) posts count

Using the below code, i have excluded the taxonomy (slug:expired) from archive or tag or taxonomies pages in front-end.

add_action('pre_get_posts','custom_get_posts');
function custom_get_posts($query) {
    
  if ( !is_admin()  $query-is_main_query() ) {
        $taxquery = array(
            array(
                'taxonomy' = 'current-status', 
                'field' = 'slug',
                'terms' = array( 'expired' ),
                'operator' = 'NOT IN'
            )
        );
        if( $query-is_post_type_archive( 'job' ) || $query-is_tag() || $query-is_tax() || $query-is_search() || $query-is_term() || $query-is_category() ){ 
          $query-set('tax_query', $taxquery );
        }
    }
}

The function excluded all the posts tagged to the taxonomy expired.

However, the term or tag post counts shows all or entire posts count. How to exclude the posts from the count? for example: without the taxonomy[expired], posts in the taxonomy[phd-positions] is 700 https://nviewscareer.com/position/phd/. But in the term counts it shows 3453 posts which includes the taxonomy[expired].

Topic pre-get-posts wp-query taxonomy Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.