Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Insert Multiple Post with Same Publish Button

This should be possible, but it will take some work. As you found out, at the end of the wp_insert_post function, there is a hook save_post_{$post->post_type}, which you can do to additional stuff when a post with a certain custom post type is created. However, if you use this hook to create additional posts, the hook will be encountered again and you end up in an infinite loop. So, you must make sure that the hook is not used the second time. It goes like this:

add_action ('save_post_yourcustompostname', 'wpse359582_make_three_posts');
function wpse359582_make_three_posts ($post_ID, $post, $update) {
  // remove the hook so it won't be called with upcoming calls to wp_insert_post
  remove_action ('save_post_yourcustompostname', 'wpse359582_make_three_posts');
  // make three copies
  $post1 = $post;
  $post2 = $post;
  $post3 = $post;
  // Now manipulate the three posts so each has a unique IMEI number
  ....
  // update the original post
  wp_update_post ($post1);
  // remove the id from the other two posts so WP will create new ones
  $post2['ID'] = 0;
  $post3['ID'] = 0;
  wp_insert_post ($post2);
  wp_insert_post ($post3);
  // put the hook back in place
  add_action ('save_post_yourcustompostname', 'wpse359582_make_three_posts');
  }

Related Posts:

  1. How to add a button to custom post type’s posts-page
  2. How often do you need to register_post_type?
  3. How to register custom post types in a plugin?
  4. How to add multiple featured image in meta box in post editor?
  5. need advice on how to do a lists using custom post types – taxonomy vs postmeta
  6. Metadata for a taxonomy – is there any WordPress way of doing this?
  7. Why is conditionally loading a custom plugin’s code only on a specific custom post type causing the site content to disappear?
  8. Getting meta in editor plugin, and event triggering issue
  9. Custom fields for custom post type
  10. Problem with adding custom post type meta to header by plugin
  11. Creating alternate meta box context locations
  12. Using publish_{custom-post-type} hook for custom post type to update meta doesn’t work
  13. Plugin Development using classes – Public & Private Callbacks
  14. Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
  15. Changing CPT permalink
  16. Correct way to register custom post type from external php file?
  17. call a function when insert and update a custom post type
  18. Execute code only after user clicks ‘update’ button for CPT being edited
  19. Create action running on trashed_post hook to modify post_meta value
  20. Custom post type template not loading from plugin
  21. I am having a problem with fetching product data in the Gutenberg block editor
  22. Custom Post Type rewrite
  23. Admin notice not displaying
  24. How to Get Current Custom Post Type Selected Taxonomy Term (Not All Terms)
  25. Custom Post Status Transition Issues With Get Post Meta
  26. Custom Post Type: Upload Multiple Images
  27. Replace title column in post list with post meta value
  28. Detect where custom post type is declared
  29. My theme saves their custom post type’s metadata as a serialized array, how to access the keys?
  30. Hooking in to an archive page?
  31. List all images from a single post meta value
  32. Does WordPress limit the length of slug names for Post Meta or Terms?
  33. Add custom column in custom post type edit page
  34. orderby in custom WP Query does not work
  35. Populate Custom Fields in a Custom Post Type?
  36. Hook to override title, image and content
  37. Update CPT post meta with update_post_meta and cron job
  38. Validate custom fields before save using WordPress Rest API
  39. Custom meta box data array: foreach not working correctly?
  40. Undefined Variable – Custom Post Type Meta
  41. get_object_taxonomies() returns empty array for custom post type
  42. Ordering posts in Search & taxonomy by post_meta
  43. How to: Display ACF [fields] on Custom Post Types Utilising WordPress ‘Hooks’? [closed]
  44. Insert post metadata for all posts in CPT at once if metadata no existent
  45. WordPress theme custom capabilities not works
  46. Display custom post type from dynamic custom field
  47. custom post type not showing in menu
  48. Custom posts don’t work
  49. Show the same Article Available in Other Categories
  50. how to delete all users and posts based on ‘user_meta’?
  51. Populate dropdown from one custom post type inside another custom post type
  52. No posts found – Custom Post Type show_ui
  53. Meta Key Value in current-user-only loop
  54. How to customize a permalink (URL) structure?
  55. Adding a custom post type taxonomy template in plugin
  56. Plugin: register custom post types, child ready and performance best practices
  57. How to add a custom taxonomy to show up in a custom post type menu?
  58. How to check if user meta field is empty in conditional else statement
  59. How to set YouTube video as featured image?
  60. Notice: Undefined index: error and understanding wordpress
  61. Posts are duplicating on wp_post_update
  62. Custom Post Types. Are there any disadvantages/advantages in using a plugin to develop them?
  63. Get posts between custom dates
  64. Give a permalink to Custom Post Types without title
  65. How to implement a Google map store locator
  66. Deleting Custom Posts & Meta Data on Uninstall
  67. Widget: Custom Post Type Post Listing Dropdown on Admin Side
  68. Getting template_include to work when allow_url_include is off?
  69. Post image in WordPress not appearing on home page
  70. How do I create an archive page as a including metadata?
  71. WordPress post_where & posts_join not working only for custom post type
  72. Add custom ID to CPT posts only create not update
  73. Add custom post type as submenu [closed]
  74. WordPress multiple custom post types capability conflict in a single menu
  75. changing meta value and meta key of price field
  76. Posting to a Custom Post Type from front end – user generated content
  77. Update Post Meta for a logged in user
  78. Orderby CPT custom fields not working
  79. How to duplicate entire custom post type
  80. A better way to add a meta box to custom post types
  81. Restrict Access to Posts based on Custom User and Post Meta Data
  82. Unable to get Custom Plugin Options data
  83. Update post meta not working in transition_post_status
  84. Two Custom Post Types Many to Many Relationship
  85. Use custom metabox to update automatically a post after a given date
  86. get_post_meta not working on publishing
  87. Should wp_postmeta meta_key always be unique for a given post_id?
  88. how can I register a post_meta field in an existing CPT and then call it again with get_post_custom()?
  89. get_post_meta returning no value in custom post type alert email
  90. Addition of custom option panel crashes Media Library & Admin Area
  91. post meta parameter in post custom-post-type endpoint with restapi
  92. How do I set all of a particular post meta to a value within the custom post type I’m in?
  93. Limit number of custom posts per taxonomy
  94. Custom Permalink to remove category word , keeping posts permalink with date?
  95. Form action/link to render a plugin in WordPress front-end
  96. Update postmeta Parent when post_status child change
  97. Metabox not show in categories custom post type cmb2
  98. What is the best practice for displaying my plugin content in themes?
  99. WordPress request fiter order by related post’s post_title
  100. Custom post type archive page blank
Categories custom-post-types Tags custom-post-types, hooks, plugin-development, post-meta
Can I set a custom “alt” attribute with woocommerce_get_product_thumbnail()?
All pages have 302 redirect, which I can’t remove

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress