trigger save_post event programmatically

It’s wp_insert_post() vs.
wp_update_post() – where update will ultimately also call:

return wp_insert_post( $postarr, $wp_error, $fire_after_hooks );

The term “once” implies that it is being fired “afterwards”.

/**
 * Fires once a post has been saved.
 *
 * @since 1.5.0
 *
 * @param int     $post_ID Post ID.
 * @param WP_Post $post    Post object.
 * @param bool    $update  Whether this is an existing post being updated.
 */
do_action( 'save_post', $post_ID, $post, $update );

When inserting a post, save_post is being fired while $fire_after_hooks is true.
And usually one may want to insert/update the record and not only fire the hook …

Leave a Comment