Title: Translate site via code insert
Last modified: April 4, 2024

---

# Translate site via code insert

 *  Resolved [lsec](https://wordpress.org/support/users/lsec/)
 * (@lsec)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/translate-site-via-code-insert/)
 * Hello,
 * I’m using the wp_insert_post() function to add new posts. Is there a way to assign
   a language to the post programmatically, thus eliminating the need for manual
   editing in the backend editor?
   `$post_data = array( ``'post_title' => $job_name,``'
   post_content' => $content, ``'post_type' => $custom_post_type, ``'post_status'
   => 'publish', ``); ``$post_id = wp_insert_post($post_data);`It gets exhausting
   when you have to manually adapt 10 posts with different content in different 
   languages.So is there any function I can use, to set a specific language to a
   post?

Viewing 1 replies (of 1 total)

 *  Plugin Support [Anca](https://wordpress.org/support/users/ancavictoria/)
 * (@ancavictoria)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/translate-site-via-code-insert/#post-17562370)
 * Hello,
 * Translations can only be added through our Translation Interface.
 * Posts do not have a language assigned to them, as they are not duplicated when
   translating. Therefore, they should be written in the default language of the
   website.
 * Kind Regards,
 * Anca

Viewing 1 replies (of 1 total)

The topic ‘Translate site via code insert’ is closed to new replies.

 * ![](https://ps.w.org/translatepress-multilingual/assets/icon.svg?rev=3166541)
 * [TranslatePress - Translate Multilingual sites with AI Translation](https://wordpress.org/plugins/translatepress-multilingual/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/translatepress-multilingual/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/translatepress-multilingual/)
 * [Active Topics](https://wordpress.org/support/plugin/translatepress-multilingual/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/translatepress-multilingual/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/translatepress-multilingual/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Anca](https://wordpress.org/support/users/ancavictoria/)
 * Last activity: [2 years, 2 months ago](https://wordpress.org/support/topic/translate-site-via-code-insert/#post-17562370)
 * Status: resolved