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.
Tagged: Custom Work
This topic contains 6 replies, has 3 voices.
Last updated by Waqas Bin Hasan 1 year, 12 months ago.
Assisted by: Waqas Bin Hasan.
Author | Posts |
---|---|
August 1, 2023 at 10:19 pm #14137995 | |
Josh Warren-White |
Tell us what you are trying to do? Is there any documentation that you are following? Is there a similar example that we can see? What is the link to your site? |
August 2, 2023 at 8:38 am #14139957 | |
Dražen Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+02:00) |
Hello, I am checking the link you shared but I see it works for 2nd language: - hidden link Let us know if you still need our help and steps on how can we see the issue. Thanks, |
August 2, 2023 at 7:23 pm #14144575 | |
Josh Warren-White |
Thanks for looking Drazen, but it's the Spanish translation that doesn't work. Spanish is in fact the only translation written for this post. Though the url "works", French is falling back to the English cause it has not been translated to French yet. Here's the Spanish link, you can see that it goes to a 404. Or when you land on the English link and then hit the translate button it also going to a 404. The other one is in English and Portugese These are the only 2 posts of this post type, media-section, that have translations written and neither work. Thanks for your continued support! |
August 3, 2023 at 1:12 pm #14149839 | |
Waqas Bin Hasan WPML Supporter since 05/2014
Languages: English (English ) Timezone: Asia/Karachi (GMT+05:00) |
Hello Josh, Thank you for contacting the support. I am assigned this ticket and can see the issue on the links you mentioned in your recent message. Before proceeding further, may I ask you to try the following? IMPORTANT: Take full backup of your website and database beforehand. It is highly advised to try the following on a staging/dev site first, so your live website isn't compromised. - Deactivate all plugins except WPML and its addons and check for the issue. Please let me know and I'll try my best to help you further on the matter. Regards. |
August 3, 2023 at 7:04 pm #14151535 | |
Josh Warren-White |
This was very helpful Waqas! Thank you! I narrowed the issue down to a pre_get_posts function we added to be able to order these custom posts by an ACF date custom field. When removed the media-section posts load in their respective translations. When there the media-section posts go to a 404. Do you have any tips on how I might modify this pre_get_posts function to make it compatible with WPML? Thank you! This is what the function looks like. function my_pre_get_posts( $query ) { // only modify queries for 'event' post type $query->set('orderby', 'meta_value'); } // return } add_action('pre_get_posts', 'my_pre_get_posts'); |
August 3, 2023 at 7:07 pm #14151537 | |
Josh Warren-White |
ps I tried setting that field to Do not translate, copy, copy once and translate. None of these setting had any effect. |
August 4, 2023 at 7:36 am #14153191 | |
Waqas Bin Hasan WPML Supporter since 05/2014
Languages: English (English ) Timezone: Asia/Karachi (GMT+05:00) |
Thanks for the updates Josh. Unfortunately the custom coding is out of scope of this forum. But I suspect you may need to take the current language (or language of the posts) into account when querying the posts. I'll recommend checking following guides: - https://wpml.org/documentation/support/wpml-coding-api/ |