WPML
SignaturePHP
do_action( 'wpml_make_post_duplicates', int $master_post_id )

Description

Builds duplicate posts from a “master” post. This action hook is reserved for front-end calls.

Arguments

  • $master_post_idintRequired

    The ID of the post to duplicate from. It can be that of a post, page or custom post. The “master post” doesn’t need to be in the default language

Example Usage

In the example below, we create duplicates for a post when we insert it from the front-end.
Our function will fire when the footer is loaded on the front-end.

PHP
add_action('wp_footer', 'my_duplicate_on_insert');
function my_duplicate_on_insert() {
	// Create post object
	$my_post = array(
	  'post_title'    => 'My post to insert from the front-end',
	  'post_content'  => 'This is my post.',
	  'post_status'   => 'publish',
	  'post_author'   => 1,
	  'post_category' => array(1)
	);

	// Insert the post into the database
	$post_id = wp_insert_post( $my_post );
	if ( $post_id ) {
		do_action( 'wpml_make_post_duplicates', $post_id );
	}
}