do_action( “{$old_status}_to_{$new_status}”, WP_Post $post )

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

Description

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

Possible hook names include:

  • draft_to_publish
  • publish_to_trash
  • pending_to_draft

Parameters

$postWP_Post
Post object.

Source

do_action( "{$old_status}_to_{$new_status}", $post );

Changelog

VersionDescription
2.3.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.