edit_post
Fires only when an existing post is updated.
This event is very similar to save_post, but it fires only when a post is updated. Therefore, all save_post examples can also be applied to edit_post.
Since version 5.1, there is an identical edit_post_(post_type) hook. Replace post_type with the post type name, and the event will fire only when a post of that type is updated.
Usage
add_action( 'edit_post', 'wp_kama_edit_post_action', 10, 2 );
/**
* Function for `edit_post` action-hook.
*
* @param int $post_id Post ID.
* @param WP_Post $post Post object.
*
* @return void
*/
function wp_kama_edit_post_action( $post_id, $post ){
// action...
}
- $post_ID(integer)
- The ID of the post being updated.
- $post(WP_Post)
- The post object being updated.
Examples
#1 Usage examples
See the description of the similar save_post hook.
Changelog
| Since 1.2.0 | Introduced. |
Where the hook is called
edit_post
edit_post
wp-includes/post.php 5242
do_action( 'edit_post', $post_id, $post );
wp-includes/class-wp-customize-manager.php 3115
do_action( 'edit_post', $post->ID, $post );
wp-includes/post.php 5458
do_action( 'edit_post', $post->ID, $post );
wp-includes/comment.php 3162
do_action( 'edit_post', $post_id, $post );