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

---

# _transition_post_status( string $new_status, string $old_status, WP_Post $post )

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/_transition_post_status/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/_transition_post_status/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/_transition_post_status/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/_transition_post_status/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/_transition_post_status/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/_transition_post_status/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/_transition_post_status/?output_format=md#changelog)

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

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Hook for managing future post transitions to published.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/_transition_post_status/?output_format=md#description)󠁿

### 󠀁[See also](https://developer.wordpress.org/reference/functions/_transition_post_status/?output_format=md#see-also)󠁿

 * [wp_clear_scheduled_hook()](https://developer.wordpress.org/reference/functions/wp_clear_scheduled_hook/)

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

 `$new_status`stringrequired

New post status.

`$old_status`stringrequired

Previous post status.

`$post`[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)required

Post object.

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

    ```php
    function _transition_post_status( $new_status, $old_status, $post ) {
    	global $wpdb;

    	if ( 'publish' !== $old_status && 'publish' === $new_status ) {
    		// Reset GUID if transitioning to publish and it is empty.
    		if ( '' === get_the_guid( $post->ID ) ) {
    			$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) );
    		}

    		/**
    		 * Fires when a post's status is transitioned from private to published.
    		 *
    		 * @since 1.5.0
    		 * @deprecated 2.3.0 Use 'private_to_publish' instead.
    		 *
    		 * @param int $post_id Post ID.
    		 */
    		do_action_deprecated( 'private_to_published', array( $post->ID ), '2.3.0', 'private_to_publish' );
    	}

    	// If published posts changed clear the lastpostmodified cache.
    	if ( 'publish' === $new_status || 'publish' === $old_status ) {
    		foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) {
    			wp_cache_delete( "lastpostmodified:$timezone", 'timeinfo' );
    			wp_cache_delete( "lastpostdate:$timezone", 'timeinfo' );
    			wp_cache_delete( "lastpostdate:$timezone:{$post->post_type}", 'timeinfo' );
    		}
    	}

    	if ( $new_status !== $old_status ) {
    		wp_cache_delete( _count_posts_cache_key( $post->post_type ), 'counts' );
    		wp_cache_delete( _count_posts_cache_key( $post->post_type, 'readable' ), 'counts' );
    	}

    	// Always clears the hook in case the post status bounced from future to draft.
    	wp_clear_scheduled_hook( 'publish_future_post', array( $post->ID ) );
    }
    ```

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

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

 [do_action_deprecated( ‘private_to_published’, int $post_id )](https://developer.wordpress.org/reference/hooks/private_to_published/)

Fires when a post’s status is transitioned from private to published.

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

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

Fires functions attached to a deprecated action hook.

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

Unschedules all events attached to the hook with the specified arguments.

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

Removes the cache contents matching key and group.

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

Retrieves the Post Global Unique Identifier (guid).

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

Returns the cache key for [wp_count_posts()](https://developer.wordpress.org/reference/functions/wp_count_posts/) based on the passed arguments.

  | 
| [wpdb::update()](https://developer.wordpress.org/reference/classes/wpdb/update/)`wp-includes/class-wpdb.php` |

Updates a row in the table.

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

Retrieves the full permalink for the current post or post ID.

  |

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

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

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

## User Contributed Notes

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