This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
This topic contains 3 replies, has 2 voices.
Last updated by Daniel 1 year, 6 months ago.
Assisted by: Nigel.
Author | Posts |
---|---|
May 24, 2023 at 8:15 pm #13711187 | |
Daniel |
Tell us what you are trying to do? Here's my code : $post_id = wp_insert_post($data_post); $attachment_id = get_post_thumbnail_id($translable_id->post_id) ; $get_language_args = array('element_id' => $translable_id->post_id, 'element_type' => 'post' ); $set_language_args = array( do_action( 'wpml_set_element_language_details', $set_language_args ); Even if I set the translated category id, it's always the french category that is set to the translated post. I've followed the documentation of 'wpml_set_element_language_details' action and tried different approach, but I got always the same result. What I'm doing wrong? WPML -> version 4.6.3 |
May 26, 2023 at 2:35 pm #13723875 | |
Daniel |
Hi, I still need assistance on this. |
May 26, 2023 at 3:07 pm #13724073 | |
Nigel Supporter Timezone: Europe/Madrid (GMT+01:00) |
Hi Dan Your site's default language is French, and you are trying to add English content, and that is indeed where the source of the problem lies. When you programmatically insert a post, it is characterised as French by WPML (the default language). I think you just need to change the sequencing a little for this to work. Insert the post without the category. You have most of the code in place that you require already, so I assume you can try that. If you get stuck, let me know. |
May 29, 2023 at 4:37 pm #13734339 | |
Daniel |
Thanks Nigel ! Your solution resolved my issue. |