Using wp_insert_post and post_update_meta but need to fire save_post afterward

I am using a calendar plugin. I have been using form data to create a new custom post type of calendar plugin and then update post meta custom fields for that calendar plugin. This works.

However there are other post meta that fired upon save_post action from the plugin classes.

I am trying to find a way to fire:

do_action( 'save_post', $post_id, $post, $update ); 

afterward. I have the $post_id but not the $post or $update. so that it fires all the methods as if I am clicking on save post in the admin.

Thank you,

1 Answer
1

You should be able to use wp_update_post() -https://codex.wordpress.org/Function_Reference/wp_update_post

Eg.

$my_post = array(
    'ID' => $post_id,
);

wp_update_post( $my_post );

The ‘save_post’ action should run when this function is called.

Leave a Comment