Update translations function
-
I have imported some posts from another cms and, now, I would like to update them with translations code.
So, I create an array ($posts) with postid and translation code (‘en’, and ‘el’) and try to use model->set_post_language to update translations with the following function.
function update_translations($translate) { global $polylang; $mydb = new wpdb('****','****','****','somewhere.dbhost'); $posts = $mydb->get_results("select nid, language from node where type in ('page') and language in ('en', 'el')"); if ($posts) { foreach ($posts as $post) { $post_id = $post['nid']; $lang = $post['language']; if ( TRUE === get_post_status( $post_id ) ) { $translate = $polylang->model->set_post_language($post_id, $lang); } } } }I suppose this function will work.. But I don’t know how to call it in order to do what it has to do.
Could you help me?
Thank you in advance!
The topic ‘Update translations function’ is closed to new replies.