Is it possible to embed a 'New Post' form for one Custom Post Type inside of a 'New Post' form for another Custom Post Type?

When a user adds a new post for the custom type 'Event', they should also be able to add a new post for the custom type 'Session' without leaving the 'New Event' page. The user should also be able to add tags for the 'Session' post only.

This is almost the same as adding a custom metabox for the 'Event' post type, with the only exception being that the Event's 'Session' data should be saved as a post rather than as a term.

1 Answer 1


Yes, it is possible to hook into save_post action of one post type and do a wp_insert_post in the other post type.


  • the Meta Box is only generated when a new post is being created.
  • the post types involved are portfolio and gallery.
  • the meta box appears in portfolio and contains only one textarea field that is used for the content of the auto generated gallery post.
  • the title of the auto generated post is the same as the original post.
  • adjust for the proper post types.
  • add fields as required.
  • adjust the post array $add_cpt_clone as required.
  • use $p_id to add tags (or custom taxonomy) to the auto-generated post. Refer to this Answer to see how to.
add_action( 'add_meta_boxes', 'add_custom_box_wpse_76945' );
add_action( 'save_post', 'save_postdata_wpse_76945', 10, 2 );

 * Meta box for PORTFOLIO post type
function add_custom_box_wpse_76945() 
    // Show ONLY when creating a NEW POST
    global $pagenow;
    if( 'post-new.php' != $pagenow )

    // Add meta box to PORTFOLIO    
        __( 'Create Post in another CPT' ),

 * Meta box content 
function inner_custom_box_wpse_76945( $post ) 
    // Use nonce for verification
    wp_nonce_field( plugin_basename( __FILE__ ), 'noncename_wpse_76945' );

    // Field for data entry
    echo '<h4>THE_CONTENT</h4>';
    echo '<textarea id="the_content_wpse_76945" name="the_content_wpse_76945" cols="90" rows="5"></textarea>';

 * Creates a new post in GALLERY post type
function save_postdata_wpse_76945( $post_id, $post_object ) 
    // Auto save?
    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )  

    // Correct post_type
    if ( 'portfolio' != $post_object->post_type )

    // Security
    if ( 
        || !wp_verify_nonce( $_POST['noncename_wpse_76945'], plugin_basename( __FILE__ ) ) 

    // Prepare contents
    $add_cpt_clone = array(
                    'post_title'   => $post_object->post_title,
                    'post_content' => $_POST['the_content_wpse_76945'],
                    'post_status'  => 'publish',
                    'post_type'    => 'gallery'

    // Insert the post into the database
    $p_id = wp_insert_post( $add_cpt_clone );

    // Use $p_id to insert new terms

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.