{$old_status}_to_{$new_status} WordPress Action Hook

The {$old_status}_to_{$new_status} hook is a great way to modify post statuses in WordPress. This hook is called whenever a post is updated to a new status, and allows you to modify the post before it is saved to the database. This hook is especially useful for custom post types, as it allows you to modify the post before it is saved to the database.

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

Top ↑

Parameters

$post

(WP_Post)Post object.


Top ↑

Source

File: wp-includes/post.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
2.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More