Title: Update translations function
Last modified: August 30, 2016

---

# Update translations function

 *  [pandreas](https://wordpress.org/support/users/pandreas/)
 * (@pandreas)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/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!
 * [https://wordpress.org/plugins/polylang/](https://wordpress.org/plugins/polylang/)

The topic ‘Update translations function’ is closed to new replies.

 * ![](https://ps.w.org/polylang/assets/icon-256x256.png?rev=3433336)
 * [Polylang](https://wordpress.org/plugins/polylang/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/polylang/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/polylang/)
 * [Active Topics](https://wordpress.org/support/plugin/polylang/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/polylang/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/polylang/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [pandreas](https://wordpress.org/support/users/pandreas/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/update-translations-function/)
 * Status: not resolved