transition_post_status
Action HookDescription
Fires when a post is transitioned from one status to another.Hook Information
File Location |
wp-includes/post.php
View on GitHub
|
Hook Type | Action |
Line Number | 5740 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$new_status
|
New post status. |
string
|
$old_status
|
Old post status. |
WP_Post
|
$post
|
Post object. |
Usage Examples
Basic Usage
<?php
// Hook into transition_post_status
add_action('transition_post_status', 'my_custom_function', 10, 3);
function my_custom_function($new_status, $old_status, $post) {
// Your custom code here
}
Source Code Context
wp-includes/post.php:5740
- How this hook is used in WordPress core
<?php
5735 *
5736 * @param string $new_status New post status.
5737 * @param string $old_status Old post status.
5738 * @param WP_Post $post Post object.
5739 */
5740 do_action( 'transition_post_status', $new_status, $old_status, $post );
5741
5742 /**
5743 * Fires when a post is transitioned from one status to another.
5744 *
5745 * The dynamic portions of the hook name, `$new_status` and `$old_status`,
PHP Documentation
<?php
/**
* Fires when a post is transitioned from one status to another.
*
* @since 2.3.0
*
* @param string $new_status New post status.
* @param string $old_status Old post status.
* @param WP_Post $post Post object.
*/
Quick Info
- Hook Type: Action
- Parameters: 3
- File: wp-includes/post.php
Related Hooks
Related hooks will be displayed here in future updates.