WPML – Change the language of large number of posts

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.

1 Answer
1

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));
}

Leave a Comment