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

Tags:

Leave a Reply

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