WPML
do_action( 'wpml_make_post_duplicates', int $master_post_id )
Type
action
WPML Version
3.2

Description

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

Arguments

$master_post_id
(int) (Required) 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.

Example
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 );
	}
}

wpml_set_element_language_details, wpml_admin_make_post_duplicates, wpml_copy_post_to_language, wpml_delete_package, wpml_import_get_trid_from_imported_translations, wpml_register_string, wpml_register_single_string, wpml_show_package_language_ui, wpml_delete_package_action

All 10 Inserting Content hooks →