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.
Here is a short video that illustrates the process of importing multilingual content using WP All Import and WPML:
To import multilingual content, you need to have the following installed:
* If you want to import WooCommerce products, you will also need WooCommerce Add-On Pro.
To import posts into 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.
- Set the unique identifier for the secondary language import to match the one you choose when importing the default language.
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!
If you want to import translations for products with taxonomy terms, you must translate those taxonomy terms before importing the products. There are two ways to do this.
The first one includes the creation of a temporary page:
- Create all of the taxonomy terms in the original language.
- Create a temporary page or a post.
- Assign all of the taxonomy terms to your temporary page.
- Send this temporary page for translation.
When you translate the temporary page all taxonomy terms can also be translated and saved. You can then delete this temporary page.
The second method is similar:
- Create all of the taxonomy terms in the original language.
- Go to WPML → Taxonomy Translation and manually translate taxonomy terms.
Now you can run the import process for translated posts. Import will automatically link translated posts with translated taxonomy terms.
To import products with manually set prices for other currencies, make sure to
set the relevant fields in the WooCommerce Add-On section for the default language import. This includes the regular price and sale price.
Additionally, you need to add the following custom fields in the default language import in order for the set prices to show correctly on the secondary language products’ pages. In our example, we have manually set prices for products in Euros. Hence, we have added the following custom fields:
As you may have noticed, some of the custom fields have the suffix _EUR. Depending on the currency you have set prices for, you need to change this suffix to match the currency code. You can get any currency code by navigating to WooCommerce -> WooCommerce Multilingual. Go to the Multi-currency tab and click on the Add currency button. There, select the currency to get its code.
If you are importing products in more than one language and they all have manually set prices for all other currencies, make sure to add custom fields associated with all the currency suffixes.
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.
Migrating from a custom database with different tables into WordPress can be a challenging task. Fortunately, you can accomplish this using Toolset plugins and WP All Import. Check Toolset’s guide on importing a database into WordPress. The video below illustrates the migration process in details:
In case you need help using WPML All Import, visit WPML’s support forum.