do_action( "save_post_{$post->post_type}", int $post_ID, WP_Post $post, bool $update )

Fires once a post has been saved.

Description Description

The dynamic portion of the hook name, $post->post_type, refers to the post type slug.

Top ↑

Parameters Parameters


(int) Post ID.


(WP_Post) Post object.


(bool) Whether this is an existing post being updated.

Top ↑

Source Source

File: wp-includes/post.php

View on Trac

Top ↑

Changelog Changelog

Version Description
3.7.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Andrew Dixon

    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.

  2. Skip to note 2 content
    Contributed by Nazmul Ahsan

    Notify your newsletter subscribers when a new book (custom post) is added-

    add_action( 'save_post_book', 'wpdocs_notify_subscribers', 10, 3 );
    function wpdocs_notify_subscribers( $post_id, $post, $update ) {
    	// If an old book is being updated, exit
    	if ( $update ) {
    	$subscribers = array( '', '', '' ); // list of your subscribers
    	$subject     = 'A new book has beed added!';
    	$message     = sprintf( 'We\'ve added a new book, %s. Click <a href="%s">here</a> to see the book', get_the_title( $post ), get_permalink( $post ) );
    	wp_mail( $subscribers, $subject, $message );

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