This glue plugin allow to import content using WP All Import and WPML.
WP All Import plugin allows you to bulk import posts, pages, WooCommerce products, and other custom post types from CSV or XML files. Now, thanks to the additional extension “WPML All Import,” it is possible to correctly import this content in language context.
To import multilingual content, you need to have the following installed:
* If you want to import WooCommerce products, you’d also need WooCommerce Add-On Pro.
To import posts to your WordPress installation, prepare CSV files. You can do this by using any spreadsheet software, such as, MS Excel or OpenOffice Calc. Prepare separate documents for posts in the original language:
And for translation(s):
When the tables are ready, use the option to export content to CSV files (in OpenOffice Calc, click menu File > Save As and choose type CSV file) and give them meaningful filenames.
Remember: Please prepare separate files with meaningful names for each language.
(Please note that this point is crucial for the successful outcome of the importing process later on.)
Importing translated content is divided into two steps (more on this below):
- Import content in the main language
- Import content in another language
During Step 2 you will have to choose from a list of already imported files (the ones that should be connected in language relation). Selecting meaningful names will make this much easier.
Second: We need a way to inform WP All Import that a row from one file is the translation of the other row from another file. To do this, add to your files a column that will inform WP All Import and WPML that the given row has a translated post coming from a row of the other file. In this column, we use “Unique Identifier” value. In WP All Import you use this field to identify every single item to import – with WPML we will use it also to identify to which group this post belongs. By looking at this ID, you can tell which post is the translation of another by finding same ID number.
You can name this column anything you like. In the example below, I call it “Connector.”
As you can see in the above screens: we have 2 CSV files English (original) english-posts.csv and Polish polish-posts.csv
The column called “Connector” groups the translations. Lines in different files (languages) that have the same “Connector” value will be considered as translations. In this way, “Hello World!” has a Polish translation of “Witaj świecie!”
Before we proceed to a description of how to import posts, let us stop for a moment to consider the case when you are importing posts with taxonomies (categories, tags, or custom taxonomies). In this case, you must create the exact same taxonomies before the import.
If after the initial import, you do another import that includes some new terms, they will not be linked to the translated terms.
If the term in the original language is not exactly the same as the term in secondary languages, you can easily fix this: simply go to the taxonomy edit screen, display the translated terms, click the link to edit it, and then choose the original term from the This is a translation of field:
However, if you want to import posts with terms that already exist and are already connected in a language relation, WP All Import will recognize it and set everything correctly IF the taxonomies and translations are already created/prepared in the new site.
Importing posts (or other post types) does not differ much from importing them when WPML is not activated: you do this according to instructions provided by WP All Import documentation authors.
You need to pay attention to a few minor things:
You need to import the first posts in the original language
Prepare your CSV/XML file with posts in the original language, as described above. Then start importing following the usual importing process.
On the main screen, you will see a WPML Add-On metabox. Make sure that the correct language is set:
Now follow the usual process.
Import posts in the second language
Now start the next import, but choose the file with the posts in the second language. Proceed as usual as you do when creating new items, but in the WPML Add-On metabox, you will have to set the correct language again. In addition, expand the section “Automatic Record Matching to Translate” and perform the following steps:
- Select the file that you used to import the original posts. (When you perform multiple imports, the list of files to select will, of course be longer.)
- Drag the field that you are using as the “connector” (see above) to the “Unique Identifier” field. This field “Unique Identifier” must be exactly the same to “Unique identifier” of the 1st (default) import.
That is it. Now proceed as usual, and this import will finish with posts in the second language that will be connected to the originals.
Importing WooCommerce simple products does not differ much from importing regular posts, as described above.
However, if you need to import WooCommerce variation products, you may need to consider some additional steps. Luckily, the team behind the WP All import plugin has prepared a very nice tutorial where they explain step by step how to achieve this. Don’t forget to add the “connector” column, as explained above!
Now that you have imported your original variable products, you need to import their translations. Besides the extra considerations for importing variable products discussed in the tutorial linked above, there is no difference when importing other post translations: prepare your CSV/XML files, add the right language on the WPML Add-On metabox and assign a Unique Identifier (connector). And it is ready to go!
WPML and WP All Import do not have an option to export posts from a WordPress installation; this is out of scope for these plugins. If you want to save a backup of your posts, you need to think about other options.
The first thing you may think of is the standard WordPress option to export content to XML files (Tools > Export). However, you will have to split those files into many (one for each language) and add an XML element with a Translation Group ID. Editing XML files is not very easy. Hence, I suggest avoiding this method of exporting content.
It will be much better to create CSV files: it is easier to split them by language and to add a column with a Translation Group ID. You can use one of these plugins as a start: WP CSV Exporter or WP CSV. Then you should divide the exported files into many (one file per each language) and add a column with information about the Translation Group ID.
You can do this manually. However, if you are a programmer, you can parse those files in PHP and for every row check the translation of the given post. You can do this with the filter wpml_object_id.