Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.