WPML
do_action( 'wpml_make_post_duplicates', int $master_post_id )
类型
action
类别
插入内容
WPML 版本
3.2

说明

从“master”文章构建复制的文章。此操作钩子专用于前端调用。

参数

$master_post_id
(int) (必填) 要从中复制的文章的 ID。它可以是文章、页面或自定义文章。“主文章”无需使用默认语言

使用示例

在下面的示例中,当从前端插入文章时,我们为其创建复制。
当在前端加载页脚时,我们的函数将会触发。

示例
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

所有 10 个 插入内容 钩子 →