Title: hook wp_insert_post
Last modified: July 9, 2023

---

# hook wp_insert_post

 *  Resolved [Lenin Zapata](https://wordpress.org/support/users/leninzapata/)
 * (@leninzapata)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/hook-wp_insert_post/)
 * Hello, I have a process where I create a post with the “wp_insert_post” hook 
   but your plugin does not generate the image, could you add the image generation
   with this hook?
 * > [View post on imgur.com](https://imgur.com/zKpnWoM)
 * [https://wordpress.stackexchange.com/questions/230750/why-is-there-both-a-save-post-and-wp-insert-post-action](https://wordpress.stackexchange.com/questions/230750/why-is-there-both-a-save-post-and-wp-insert-post-action)
    -  This topic was modified 2 years, 9 months ago by [Lenin Zapata](https://wordpress.org/support/users/leninzapata/).

Viewing 1 replies (of 1 total)

 *  Plugin Author [Alexandre Gaboriau](https://wordpress.org/support/users/mcurly/)
 * (@mcurly)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/hook-wp_insert_post/#post-16883715)
 * Hi Lenin,
 * Maybe you can try with this code:
 *     ```wp-block-code
       function MPT_wp_insert_post($post_id, $post, $update) {
       	$plugin = new Magic_Post_Thumbnail();
       	$plugin_admin = new Magic_Post_Thumbnail_Admin( $plugin->get_plugin_name(), $plugin->get_version() );
       	$launch_plugin = $plugin_admin->MPT_trigger_wp_insert_post($post_id);
       }
   
   
       add_action( 'wp_insert_post', 'MPT_wp_insert_post', 15, 3 );
       ```
   
 * But be careful, this code can also assign an image when you add a post manually
   with the back office, so I didn’t include this code in the plugin.

Viewing 1 replies (of 1 total)

The topic ‘hook wp_insert_post’ is closed to new replies.

 * ![](https://ps.w.org/magic-post-thumbnail/assets/icon-256x256.png?rev=3183991)
 * [Generate Images (AI) - Magic Post Thumbnail](https://wordpress.org/plugins/magic-post-thumbnail/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/magic-post-thumbnail/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/magic-post-thumbnail/)
 * [Active Topics](https://wordpress.org/support/plugin/magic-post-thumbnail/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/magic-post-thumbnail/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/magic-post-thumbnail/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Alexandre Gaboriau](https://wordpress.org/support/users/mcurly/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/hook-wp_insert_post/#post-16883715)
 * Status: resolved