Title: delete_transient
Published: April 25, 2014
Last modified: May 20, 2026

---

# delete_transient( string $transient ): bool

## In this article

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

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

Deletes a transient.

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

 `$transient`stringrequired

Transient name. Expected to not be SQL-escaped.

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

 bool True if the transient was deleted, false otherwise.

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

    ```php
    function delete_transient( $transient ) {

    	/**
    	 * Fires immediately before a specific transient is deleted.
    	 *
    	 * The dynamic portion of the hook name, `$transient`, refers to the transient name.
    	 *
    	 * @since 3.0.0
    	 *
    	 * @param string $transient Transient name.
    	 */
    	do_action( "delete_transient_{$transient}", $transient );

    	if ( wp_using_ext_object_cache() || wp_installing() ) {
    		$result = wp_cache_delete( $transient, 'transient' );
    	} else {
    		$option_timeout = '_transient_timeout_' . $transient;
    		$option         = '_transient_' . $transient;
    		$result         = delete_option( $option );

    		if ( $result ) {
    			delete_option( $option_timeout );
    		}
    	}

    	if ( $result ) {

    		/**
    		 * Fires after a transient is deleted.
    		 *
    		 * @since 3.0.0
    		 *
    		 * @param string $transient Deleted transient name.
    		 */
    		do_action( 'deleted_transient', $transient );
    	}

    	return $result;
    }
    ```

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

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/delete_transient/?output_format=md#hooks)󠁿

 [do_action( ‘deleted_transient’, string $transient )](https://developer.wordpress.org/reference/hooks/deleted_transient/)

Fires after a transient is deleted.

 [do_action( “delete_transient_{$transient}”, string $transient )](https://developer.wordpress.org/reference/hooks/delete_transient_transient/)

Fires immediately before a specific transient is deleted.

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

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

Checks or sets whether WordPress is in “installation” mode.

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

Removes the cache contents matching key and group.

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

Toggles `$_wp_using_ext_object_cache` on and off without directly touching global.

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

Removes an option by name. Prevents removal of protected WordPress options.

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

Calls the callback functions that have been added to an action hook.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/delete_transient/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/delete_transient/?output_format=md#)

| Used by | Description | 
| [WP_Automatic_Updater::has_fatal_error()](https://developer.wordpress.org/reference/classes/wp_automatic_updater/has_fatal_error/)`wp-admin/includes/class-wp-automatic-updater.php` |

Performs a loopback request to check for potential fatal errors.

  | 
| [wp_edit_theme_plugin_file()](https://developer.wordpress.org/reference/functions/wp_edit_theme_plugin_file/)`wp-admin/includes/file.php` |

Attempts to edit a file for a theme or plugin.

  | 
| [wp_dashboard_rss_control()](https://developer.wordpress.org/reference/functions/wp_dashboard_rss_control/)`wp-admin/includes/dashboard.php` |

Sets up the RSS dashboard widget control and $args to be used as input to [wp_widget_rss_form()](https://developer.wordpress.org/reference/functions/wp_widget_rss_form/) .

  | 
| [wp_upgrade()](https://developer.wordpress.org/reference/functions/wp_upgrade/)`wp-admin/includes/upgrade.php` |

Runs WordPress Upgrade functions.

  | 
| [get_settings_errors()](https://developer.wordpress.org/reference/functions/get_settings_errors/)`wp-admin/includes/template.php` |

Fetches settings errors registered by [add_settings_error()](https://developer.wordpress.org/reference/functions/add_settings_error/) .

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

Maybe attempts to generate attachment metadata, if missing.

  | 
| [__clear_multi_author_cache()](https://developer.wordpress.org/reference/functions/__clear_multi_author_cache/)`wp-includes/author-template.php` |

Helper function to clear the cache for number of authors.

  |

[Show 2 more](https://developer.wordpress.org/reference/functions/delete_transient/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/delete_transient/?output_format=md#)

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

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

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

 1.   [Skip to note 3 content](https://developer.wordpress.org/reference/functions/delete_transient/?output_format=md#comment-content-4180)
 2.    [Denis Alemán](https://profiles.wordpress.org/barmaglot7/)  [  6 years ago  ](https://developer.wordpress.org/reference/functions/delete_transient/#comment-4180)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fdelete_transient%2F%23comment-4180)
     Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fdelete_transient%2F%23comment-4180)
 4.  **Cache invalidation**
 5.  If data (posts, terms, users, comments, etc.) has been updated, previously cached
     data, being retrieved from transients, might be invalid.
 6.  **Flush explicitly corresponding transients using the following action hooks:**
 7.   * in case a new post has been created, use [_save\_post_](https://developer.wordpress.org/reference/hooks/save_post/)
        or _publish\_post_:
      *     ```php
            add_action( 'save_post', 'wpdocs_delete_my_important_transient' );
            function wpdocs_delete_my_important_transient() {
            	// check status here or check if post data has been changed
            	delete_transient( 'wpdocs_my_transient_name' );
            }
            ```
        
      * in case any post has been deleted, use [_deleted\_post_](https://developer.wordpress.org/reference/hooks/deleted_post/):
      *     ```php
            add_action( 'deleted_post', 'wpdocs_delete_my_important_transient' );
            function wpdocs_delete_my_important_transient() {
            	delete_transient( 'wpdocs_my_transient_name' );
            }
            ```
        
      * when post has been edited, [_edit\_post_](https://developer.wordpress.org/reference/hooks/edit_post/)
      *     ```php
            add_action( 'edit_post', 'wpdocs_delete_my_important_transient' );
            function wpdocs_delete_my_important_transient() {
            	delete_transient( 'wpdocs_my_transient_name' );
            }
            ```
        
      * in case of custom post types, e.g. book, you can use _edit\_post\_book_, _save\
        _post\_book_
 8.  **NOTE:** In some cases you might need to check post status, for example, when
     you move post to trash or restore it.
 9.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fdelete_transient%2F%3Freplytocom%3D4180%23feedback-editor-4180)
 10.  [Skip to note 4 content](https://developer.wordpress.org/reference/functions/delete_transient/?output_format=md#comment-content-1217)
 11.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/delete_transient/#comment-1217)
 12. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fdelete_transient%2F%23comment-1217)
     Vote results for this note: -1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fdelete_transient%2F%23comment-1217)
 13. **Clearing our transient via the edit_term hook**
 14.     ```php
         // Create a simple function to delete our transient
         function wpdocs_edit_term_delete_transient() {
              delete_transient( 'special_query_results' );
         }
         // Add the function to the edit_term hook so it runs when categories/tags are edited
         add_action( 'edit_term', 'wpdocs_edit_term_delete_transient' );
         ```
     
 15.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fdelete_transient%2F%3Freplytocom%3D1217%23feedback-editor-1217)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fdelete_transient%2F)
before being able to contribute a note or feedback.