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_post
save_post_page
Parameters
$post_id
int- Post ID.
$post
WP_Post- Post object.
$update
bool- Whether this is an existing post being updated.
Source
do_action( "save_post_{$post->post_type}", $post_id, $post, $update );
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_post
function as well.It’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-