WordPress action hook · part of WordPress core

wp_insert_post

A WordPress core action that 32 plugins also fire themselves, running on 546K+ sites between them.

“This action is documented in wp-includes/post.php”

How to use wp_insert_post

It's an action: your callback runs at that point and receives 3 arguments. Nothing needs to be returned. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_action( 'wp_insert_post', function( $ID, $post, $arg3 ) {
	// Your code runs here.
}, 10, 3 );

Argument names come from Page Builder by SiteOrigin's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

This hook is fired by WordPress core too. Official reference on developer.wordpress.org →

32 plugins that fire wp_insert_post

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. Page Builder by SiteOrigin icon Page Builder by SiteOrigin400,000+ installs do_action( 'wp_insert_post', $post->ID, $post, true ) inc/admin.php:1280
  2. WP All Import icon WP All Import100,000+ installs do_action( 'wp_insert_post', $pid, $post_object, $is_update ) models/import/record.php:4196
  3. Editorial Calendar icon Editorial Calendar20,000+ installs do_action( 'wp_insert_post', $edcal_postid, $post, true ) edcal.php:1356
  4. Royal MCP icon Royal MCP10,000+ installs do_action( 'wp_insert_post', $post_id, $post, true ) includes/MCP/Support/Post_Write_Hooks.php:59
  5. Admin Management Xtended icon Admin Management Xtended5,000+ installs do_action( 'wp_insert_post', $postid, $post ) admin-management-xtended.php:179
  6. WSP MCP icon WSP MCP3,000+ installs do_action( 'wp_insert_post', $post_id, $post, true ) includes/abilities/yoast.php:50
  7. Seamless Donations is Sunset icon Seamless Donations is Sunset2,000+ installs do_action( 'wp_insert_post', $post_ID, $post, $update ) inc/utilities.php:1806
  8. BrikPanel: WooCommerce Dashboard & Analytics, Abandoned Cart Recovery, Order Export, Inventory Management & Bulk Editor icon BrikPanel: WooCommerce Dashboard & Analytics, Abandoned Cart Recovery, Order Export, Inventory Management & Bulk Editor1,000+ installs do_action( 'wp_insert_post', $saved_id, $post_obj, true ) front-end/products/brikpanel-product-editor.php:10714
  9. WP Sync for Notion icon WP Sync for Notion1,000+ installs do_action( 'wp_insert_post', $existing_object_id, get_post( $existing_object_id ), true ) modules/post/class-notion-wp-sync-post-importer.php:205
  10. Air WP Sync icon Air WP Sync1,000+ installs do_action( 'wp_insert_post', $post_id, get_post( $post_id ), true ) modules/post/class-air-wp-sync-post-importer.php:171
  11. Expiring Posts icon Expiring Posts1,000+ installs do_action( 'wp_insert_post', $post->ID, $post ) expiring-posts.php:412
  12. Oasis Workflow icon Oasis Workflow600+ installs do_action( 'wp_insert_post', $post->ID, $post, true ) includes/class-ow-process-flow.php:1098
  13. TMDS icon TMDS400+ installs do_action( 'wp_insert_post', $post_id, $post, $update ) includes/class/tmds-products-table.php:478
  14. WordLift icon WordLift300+ installs do_action( 'wp_insert_post', $post->ID, $post, true ) admin/wordlift-admin-save-post.php:104
  15. Web Directory plugin Free icon Web Directory plugin Free300+ installs do_action( 'wp_insert_post', $post_id, $post, true ) core/classes/listings/listing_form_assets.php:891
  16. WPMelon Advanced Bulk Edit for WooCommerce icon WPMelon Advanced Bulk Edit for WooCommerce300+ installs do_action( 'wp_insert_post', $post->ID, $post, true ) includes/Handlers/WP_Save_Hooks_Handler.php:258
  17. MEGA AI icon MEGA AI200+ installs do_action( 'wp_insert_post', $post_id, $post_after, true ) mega.php:8895
  18. ChinaDS icon ChinaDS100+ installs do_action( 'wp_insert_post', $post_id, $post, $update ) admin/taobao-products-table.php:476
  19. HANDMADE icon HANDMADE40+ installs do_action( 'wp_insert_post', $post_id, $post, $update ) includes/class/handmade-products-table.php:478
  20. Depublish Posts icon Depublish Posts30+ installs do_action( 'wp_insert_post', $post->ID, $post, true ) src/Post.php:96
  21. CBIAStudio BlogFlow with AI icon CBIAStudio BlogFlow with AI20+ installs do_action( 'wp_insert_post', $post_id, get_post($post_id), true ) includes/integrations/yoast-legacy.php:154
  22. Post ID Optimizer icon Post ID Optimizer10+ installs do_action( 'wp_insert_post', $post_ID, $post, $update ) post-poidopt.php:3968
  23. Dynamic Functionalities icon Dynamic Functionalities10+ installs do_action( 'wp_insert_post', $post_id, $after, true ) includes/features/class-link-health-editor.php:241
  24. ProRank SEO icon ProRank SEO10+ installs do_action( 'wp_insert_post', $id, $after, true ) includes/Core/Content/PostContentWriter.php:79
  25. Vacation Rentals icon Vacation Rentals10+ installs do_action( 'wp_insert_post', 'wp_insert_post' ) assets/rental/frontend/class-edit-rental.php:113
  26. CRAI Content Updater icon CRAI Content UpdaterFewer than 10 installs do_action( 'wp_insert_post', $original_id, $updated_post, true ) includes/class-crai-updater.php:1368
  27. Your SEO Squad icon Your SEO SquadFewer than 10 installs do_action( 'wp_insert_post', $id, $post, true ) your-seo-squad.php:1708
  28. PerfLocale icon PerfLocaleFewer than 10 installs do_action( 'wp_insert_post', $post_id, $after, true ) src/Translation/PostSlugCheck.php:144
  29. Zeopilot icon ZeopilotFewer than 10 installs do_action( 'wp_insert_post', $id, $post, true ) conditional-content.php:197
  30. show.fm Podcast Player icon show.fm Podcast PlayerFewer than 10 installs do_action( 'wp_insert_post', $post->ID, $updated, true ) includes/class-migration-swap.php:169
  31. Super Speedy Imports Lite icon Super Speedy Imports LiteFewer than 10 installs do_action( 'wp_insert_post', (int)$post_id, $post, (bool)$is_update ) tools/class-save-posts-tool.php:95
  32. IPS Order Media Cleanup icon IPS Order Media CleanupFewer than 10 installs do_action( 'wp_insert_post', $object_id, $post, true ) includes/classes/Media/Recovery/ReferenceJournal.php:66

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.