Fires once a post has been saved.
Description
The dynamic portion of the hook name, $post->post_type, refers to the post type slug.
Possible hook names include:
save_post_postsave_post_page
Parameters
$post_idint- Post ID.
$postWP_Post- Post object.
$updatebool- Whether this is an existing post being updated.
Source
do_action( "save_post_{$post->post_type}", $post_id, $post, $update );
View all references View on Trac View on GitHub
Related
| 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 updates a post in the database. |
Changelog
| Version | Description |
|---|---|
| 3.7.0 | Introduced. |
The hook also fires when clicking on the “Add New” option for the custom post type, as it creates the draft in the DB, and when calling the
wp_update_postfunction as well.-
You can know whether the hook fired from the “Add New” option by checking the post status:
Benjamin Intal 7 years ago
Log in to add feedbackIt’s also good to note that this hook is also called when trashing a post or restoring it from trash.
It’s kind of sad that this more explicit action fires before the less explicit ‘save_post’ action.
This means if a 3rd party plugin does something using ‘save_post’ you need to use ‘save_post’ to override it too.
Notify your newsletter subscribers when a new book (custom post) is added-