do_action( 'wpml_make_post_duplicates', int $master_post_id )
- Type
- action
- Catégorie
- Insertion de contenu
- Version de WPML
- 3.2
Description
Crée des articles dupliqués à partir d’un article « maître ». Ce hook d’action est réservé aux appels de l’interface publique.
Arguments
- $master_post_id
- (int) (Requis) L’ID de l’article à partir duquel dupliquer. Il peut s’agir de celui d’un article, d’une page ou d’un type de publication personnalisé. L’« article maître » n’a pas besoin d’être dans la langue par défaut.
Exemple d’utilisation
Dans l’exemple ci-dessous, nous créons des duplicatas pour un article lorsque nous l’insérons depuis l’interface publique.
Notre fonction se déclenchera lorsque le pied de page sera chargé sur l’interface publique.
Exemple
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 );
}
}
Hooks associés
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