<old_status>_to_<new_status>

Fires when a post is transitioned from one status to another.

Description

do_action( '<old_status>_to_<new_status>', (WP_Post) $post ); 

The dynamic portions of the hook name refer refer to the old and new post statuses, respectively.

Parameters (1)

0. $post (WP_Post)
Post object.

Usage

To run the hook, copy the example below.
  1. // run the action 
  2. do_action( '{$old_status}_to_{$new_status}', $post ); 
The following example is for adding a hook callback.
  1. // define the <old_status>_to_<new_status> callback 
  2. function action_old_status_to_new_status( $post ) { 
  3. // make action magic happen here... 
  4. }; 
  5.  
  6. // add the action 
  7. add_action( "{$old_status}_to_{$new_status}", 'action_old_status_to_new_status', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the action 
  2. remove_action( "{$old_status}_to_{$new_status}", 'action_old_status_to_new_status', 10, 1 ); 

Defined (1)

The action is defined in the following location(s).

/wp-includes/post.php  
  1. do_action( "{$old_status}_to_{$new_status}", $post );