save_post_<post_type>
Fires once a post has been saved.
Description
The dynamic portion(s) of the hook name refer to the post type slug.
Parameters (3)
- 0. $post_id (int)
- The post id.
- 1. $post (WP_Post)
- Post object.
- 2. $update (bool)
- Whether this is an existing post being updated or not.
Usage
- To run the hook, copy the example below.
- // run the action
- do_action( 'save_post_{$post_type}', $post_id, $post, $update );
- The following example is for adding a hook callback.
- // define the save_post_<post_type> callback
- function action_save_post_post_type( $post_id, $post, $update ) {
- // make action magic happen here...
- };
- // add the action
- add_action( "save_post_{$post_type}", 'action_save_post_post_type', 10, 3 );
- To remove a hook callback, use the example below.
- // remove the action
- remove_action( "save_post_{$post_type}", 'action_save_post_post_type', 10, 3 );
Defined (3)
The action is defined in the following location(s).
- /wp-includes/post.php
- do_action( "save_post_{$post->post_type}", $post_ID, $post, $update );
- do_action( "save_post_{$post->post_type}", $post->ID, $post, true );
- /wp-includes/theme.php
- do_action( "save_post_{$post->post_type}", $post->ID, $post, true );