sitepress->get_current_language(); $this->sitepress->switch_lang( $lang, false ); if ( isset( $postarr['ID'] ) ) { $new_post_id = wp_update_post( $postarr, $wp_error ); } else { $new_post_id = wp_insert_post( $postarr, $wp_error ); } $this->sitepress->switch_lang( $current_language, false ); return $new_post_id; } }