• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress core a2z

WordPress core a2z

WordPress core only

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / wp_update_term_count() – Updates the amount of terms in taxonomy.

You appear to be a bot. Output may be restricted

Description

Updates the amount of terms in taxonomy.

If there is a taxonomy callback applied, then it will be called for updating the count. The default action is to count what the amount of terms have the relationship of term ID. Once that is done, then update the database.

Usage

$bool = wp_update_term_count( $terms, $taxonomy, $do_deferred );

Parameters

$terms
( int|array ) required – The term_taxonomy_id of the terms.
$taxonomy
( string ) required – The context of the term.
$do_deferred
( bool ) optional – Whether to flush the deferred term counts too. Default false.

Returns

bool If no terms will return false, and if successful will return true.

Source

File name: wordpress/wp-includes/taxonomy.php
Lines:

1 to 28 of 28
function wp_update_term_count( $terms, $taxonomy, $do_deferred = false ) {
  static $_deferred = array();

  if ( $do_deferred ) {
    foreach ( (array) array_keys( $_deferred ) as $tax ) {
      wp_update_term_count_now( $_deferred[ $tax ], $tax );
      unset( $_deferred[ $tax ] );
    }
  }

  if ( empty( $terms ) ) {
    return false;
  }

  if ( ! is_array( $terms ) ) {
    $terms = array( $terms );
  }

  if ( wp_defer_term_counting() ) {
    if ( ! isset( $_deferred[ $taxonomy ] ) ) {
      $_deferred[ $taxonomy ] = array();
    }
    $_deferred[ $taxonomy ] = array_unique( array_merge( $_deferred[ $taxonomy ], $terms ) );
    return true;
  }

  return wp_update_term_count_now( $terms, $taxonomy );
}
 

 View on GitHub View on Trac

Published: 25th November 2019 | Last updated: 25th November 2019

Primary Sidebar

Information

Function name: wp_update_term_count
Plugin ref: WordPress
Version: 5.6
Sourcefile: wp-includes/taxonomy.php
File ref: wp-includes/taxonomy.php
Deprecated?: No
API Letters: C,T,U,W

Footer

WP-a2z
WordPress core a2z
WordPress core only
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  core.wp-a2z.org
© Copyright WP-a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites