Title: wp_defer_term_counting
Published: April 25, 2014
Last modified: February 24, 2026

---

# wp_defer_term_counting( bool $defer = null ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_defer_term_counting/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_defer_term_counting/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_defer_term_counting/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_defer_term_counting/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_defer_term_counting/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_defer_term_counting/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_defer_term_counting/?output_format=md#wp--skip-link--target)

Enables or disables term counting.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_defer_term_counting/?output_format=md#parameters)󠁿

 `$defer`booloptional

Enable if true, disable if false.

Default:`null`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_defer_term_counting/?output_format=md#return)󠁿

 bool Whether term counting is enabled or disabled.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_defer_term_counting/?output_format=md#source)󠁿

    ```php
    function wp_defer_term_counting( $defer = null ) {
    	static $_defer = false;

    	if ( is_bool( $defer ) ) {
    		$_defer = $defer;
    		// Flush any deferred counts.
    		if ( ! $defer ) {
    			wp_update_term_count( null, null, true );
    		}
    	}

    	return $_defer;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/taxonomy.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/taxonomy.php#L3511)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/taxonomy.php#L3511-L3523)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_defer_term_counting/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_update_term_count()](https://developer.wordpress.org/reference/functions/wp_update_term_count/)`wp-includes/taxonomy.php` |

Updates the amount of terms in taxonomy.

  |

| Used by | Description | 
| [wp_nav_menu_update_menu_items()](https://developer.wordpress.org/reference/functions/wp_nav_menu_update_menu_items/)`wp-admin/includes/nav-menu.php` |

Saves nav menu items.

  | 
| [wp_update_term_count()](https://developer.wordpress.org/reference/functions/wp_update_term_count/)`wp-includes/taxonomy.php` |

Updates the amount of terms in taxonomy.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_defer_term_counting/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.5.0](https://developer.wordpress.org/reference/since/2.5.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_defer_term_counting/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/wp_defer_term_counting/?output_format=md#comment-content-1474)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/wp_defer_term_counting/#comment-1474)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_defer_term_counting%2F%23comment-1474)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_defer_term_counting%2F%23comment-1474)
 4. Designed to speed up the process of inserting multiple posts during an import by
    temporarily disabling term counts until all posts have been inserted.
 5. Original trac article: [https://core.trac.wordpress.org/ticket/5377](https://core.trac.wordpress.org/ticket/5377)
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_defer_term_counting%2F%3Freplytocom%3D1474%23feedback-editor-1474)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_defer_term_counting%2F)
before being able to contribute a note or feedback.