Categories
programming

Update posts language after installing WPML plugin for wordpress

WPML is a plugin that enables a worpress site to write post in different languages. You only have to install the plugin and all works.. wel not all. If you already have lot of articles written in your language, the main page of your site will show anything due that there is no pages with that language. However, you can execute a small SQL sentence to solve this problem, here we go:

INSERT INTO wp_icl_translations(element_type, element_id, trid, language_code)
SELECT 'post', `ID`, 1, "es" FROM `wp_posts` WHERE `post_status`="publish"

and for the categories also:

INSERT INTO wp_icl_translations(element_type, element_id, trid, language_code)
SELECT 'category', `term_taxonomy_id`, 0, "es" FROM `wp_term_taxonomy` WHERE `taxonomy`="category";

and last, make some cleaning tasks:

UPDATE `wp_icl_translations` SET `source_language_code` = ""

* Replace the “es” string with the appropriate language.

3 replies on “Update posts language after installing WPML plugin for wordpress”

Very nice writeup. We’re planning to add some multilingual import to WPML, which will allow attaching existing translations to each other. Meaning, you’ll be able to say “This post is the Spanish translation of OTHER_POST”.

This way, if you’ve already got multilingual contents arranged in different categories, you’ll be able to associate between them.

@Amir Helzer, nice also to hear about new features, but what we need is better support to add the plugin to blogs that already have contents.

Best is to open a new issue in our forum and we can follow up on it.
http://forum.wpml.org

You can describe how to existing contents are organized and we’ll see how they can be imported systematically.

As you wrote in your post, the wp_icl_translations table needs to be manipulated. The thing is, you need to do it so that contents in different languages are associated to the same translation group. This way, they appear as translations of each other.

Leave a Reply

Your email address will not be published. Required fields are marked *