On this page
do_action( 'wp_insert_post', int $post_ID, WP_Post $post, bool $update )
Fires once a post has been saved.
Parameters
$post_IDint-
Post ID.
$postWP_Post-
Post object.
$updatebool-
Whether this is an existing post being updated.
More Information
The wp_insert_post action fires once a post has been saved. You have the ability to set it to only fire on new posts or on all save actions using the parameters. Please see Plugin_API/Action_Reference/save_post for more information. Keep in mind that this action is called both for actions in the admin as well as anytime the wp_insert_post() function is invoked.
This action can be replicated by creating a conditional in a save_post action that excludes certain post statuses.
An important distinction of wp_insert_post action is that it is fired after update_post_meta has been called.
Source
File: wp-includes/post.php. View all references
do_action( 'wp_insert_post', $post_ID, $post, $update );
Related
Used By
| Used By | Description |
|---|---|
| WP_Customize_Manager::trash_changeset_post() wp-includes/class-wp-customize-manager.php | Trashes or deletes a changeset post. |
| wp_publish_post() wp-includes/post.php | Publishes a post by transitioning the post status. |
| wp_insert_post() wp-includes/post.php | Inserts or update a post. |
Changelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/hooks/wp_insert_post