wp_after_insert_post
Action HookDescription
Fires once a post, its terms and meta data has been saved.Hook Information
File Location |
wp-includes/post.php
View on GitHub
|
Hook Type | Action |
Line Number | 5831 |
Hook Parameters
Type | Name | Description |
---|---|---|
int
|
$post_id
|
Post ID. |
WP_Post
|
$post
|
Post object. |
bool
|
$update
|
Whether this is an existing post being updated. |
null|WP_Post
|
$post_before
|
Null for new posts, the WP_Post object prior to the update for updated posts. |
Usage Examples
Basic Usage
<?php
// Hook into wp_after_insert_post
add_action('wp_after_insert_post', 'my_custom_function', 10, 4);
function my_custom_function($post_id, $post, $update, $post_before) {
// Your custom code here
}
Source Code Context
wp-includes/post.php:5831
- How this hook is used in WordPress core
<?php
5826 * @param WP_Post $post Post object.
5827 * @param bool $update Whether this is an existing post being updated.
5828 * @param null|WP_Post $post_before Null for new posts, the WP_Post object prior
5829 * to the update for updated posts.
5830 */
5831 do_action( 'wp_after_insert_post', $post_id, $post, $update, $post_before );
5832 }
5833
5834 //
5835 // Comment, trackback, and pingback functions.
5836 //
PHP Documentation
<?php
/**
* Fires once a post, its terms and meta data has been saved.
*
* @since 5.6.0
*
* @param int $post_id Post ID.
* @param WP_Post $post Post object.
* @param bool $update Whether this is an existing post being updated.
* @param null|WP_Post $post_before Null for new posts, the WP_Post object prior
* to the update for updated posts.
*/
Quick Info
- Hook Type: Action
- Parameters: 4
- File: wp-includes/post.php
Related Hooks
Related hooks will be displayed here in future updates.