WPML

My crossposting plugins support WPML translations.

In order to make them work all you need to do is to download a free add-on below and (network) activate it. It is mandatory – if you’re using WPML and you haven’t installed this add-on, the posts will be either crossposted without a language assigned (so they just aren’t going to be displayed on subsites) or with a default language.

Below is the add-on for the multisite version of the plugin:

Download Simple Multisite Crossposting – WPML 2.1

Below is the add-on for the non-multisite version of the plugin. It also requires a code snippet to be installed on subsites!

Download Simple WP Crossposting – WPML 1.0

Now you can create posts and translation posts for them as usual. All you need to do it is to crosspost both original posts and translations. The add-on you downloaded will connect them automatically! In order to make this process more clear and convenient I recommend to use “WordPress editor” for translations:

Using WordPress editor for translations in WPML
Just hit the “+” button.

One more thing when you’re crossposting a WooCommerce product translation while using WPML + Simple Multisite Crossposting + WCML (WooCommerce Multilingual and Multicurrency) – if you get a message like below, it means that WPML hasn’t fully created a translation yet and you need to save it first and only then to crosspost, otherwise you get an error message “Product has no SKU”.

WPML product translation creation
As you can see, product fields like “Regular price”, “Sale Price” and others are empty and non-editable. WPML requires us to save a translated product manually in order for it to populate its fields. An unnecessary extra step maybe but that’s how WPML works.

What to do if you have already crossposted a bunch of posts without the add-on activated and now those posts are invisible? Easy enough – you can just deactivate WPML for a while and remove those broken posts.

Code Snippet (only for non-multisite version)

If you are using Simple WordPress Crossposting plugin, then it is required to do one more extra step. It is super-easy, all you need to do is just to copy and paste the following snippet below to all the sub-sites you’re going to crosspost to.

add_action( 'rest_after_insert_post', 'rudr_swc_wpml_snippet', 99, 2 ); // for Posts
add_action( 'rest_after_insert_page', 'rudr_swc_wpml_snippet', 99, 2 ); // for Pages
// for custom post types duplicate this line:
// add_action( 'rest_after_insert_{POST TYPE NAME}', 'rudr_swc_wpml_snippet', 99, 2 );
function rudr_swc_wpml_snippet( $post, $request ) {

	if( ( ! $lang = $request->get_param( 'lang' ) ) || ( ! $translations = $request->get_param( 'translations' ) ) ) {
		return;
	}
	
	foreach( $translations as $translated_post_id ) { // as $lang_code => $translated_post_id
		$lang_data = apply_filters( 'wpml_element_language_details', null, array( 'element_id' => $translated_post_id, 'element_type' => 'post' ) );
		do_action( 'wpml_set_element_language_details', array( 'element_id' => $post->ID, 'element_type' => 'post_' . get_post_type( $post->ID ), 'trid' => $lang_data->trid, 'language_code' => $lang, 'source_language_code' => $lang_data->language_code ) );
	}

}

// for WooCommerce
// add_filter( 'wc_product_has_unique_sku', '__return_false' );

If you don’t know where to use this code snippet, please check this guide or watch the video below:

Need more help?