WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to change the language of some 500 posts in a site that uses WPML. Currently all of them are set to English, but are in fact in Spanish.

What is the fastest way to do so? It is possible to get the IDs of all of the posts.

share|improve this question
up vote 2 down vote accepted

I've done it with this bit of code:

global $wpdb;

$posts = get_posts(array('post_type'=>'...', 'posts_per_page'=>-1));
foreach($posts as $post) {
    $wpdb->update('wp_icl_translations', array('language_code'=>'es'), array('element_id'=> $post->ID));
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.