deepl_translate_post_link | WordPress.org

[ad_1]

Would you like the post insertion to launch a translation, or would you like a translation to insert a post ? ๐Ÿ™‚

Thank you for your reply.
Our site is bilingual French/English (WPML).
I use Buddypress for the forums.
I would like a message written in English to be translated into French and vice versa.
For the moment, itโ€™s simply duplicated in the other language. Using the wp_insert_post hook, I can modify the content with wp_update_post.
I just need to translate the content, and the title, before applying wp_update_post.
Iโ€™d like to use a plugin function for this.

I hope Iโ€™ve made myself clear!
Sincerely
Emmanuel Liron

Cโ€™est clair ๐Ÿ™‚

Youโ€™ll need to add something like this somewhere :

add_action('wp_insert_post', 'mysite_translate_post', 10, 3);
function mysite_translate_post( $new_post_id, $WP_Post, $update) { 
	if( $update ) return;
	$args = array(
		'ID'	=> $new_post_id,
		'target_lang'	=> 'en_GB',
	);
	$updated = deepl_translate_post_link( $args );
}
  • This reply was modified 9 minutes ago by malaiac.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer