This thread is resolved. Here is a description of the problem and solution.
Problem:
You are experiencing issues with translated posts not being found due to complex permalink structures and custom rewrite rules in a multilingual WordPress setup using WPML.
Solution:
We recommend modifying the timing of your redirect rules. Instead of loading your redirects on 'init', try using the 'wpml-loaded' action. This ensures that WPML's language handling is fully loaded before your custom rewrite rules are applied, which helps in maintaining the correct language directories in URLs. For more details on this hook, please visit https://wpml.org/wpml-hook/wpml_loaded/.
If this solution does not resolve your issue or seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. Should you need further assistance, please do not hesitate to open a new support ticket at WPML support forum.
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 18 replies, has 2 voices.
Last updated by Andreas W. 2 months ago.
Assisted by: Andreas W..
Author | Posts |
---|---|
September 23, 2024 at 6:02 pm #16211348 | |
davidH-179 |
<b>Background of the issue: </b> <b>Symptoms: </b> <b>Questions: </b> |
September 23, 2024 at 6:32 pm #16211443 | |
Andreas W. Supporter Languages: English (English ) Spanish (Español ) German (Deutsch ) Timezone: America/Lima (GMT-05:00) |
Hello, Is your CPT set to be translatable inside WPML > Settings > Post Type Translation? Guide: Usually, you further should translate the CPT slug with WPML > String Translation. Guide: If this did not clarify the cause of the issue, was this CPT integrated into your theme or was it created with ACF or another plugin? Best regards |
September 23, 2024 at 7:37 pm #16211679 | |
davidH-179 |
Yes we've set them to be translateable. The String translation is not the issue I don't think. I think the issue may be because we have a complicated permalinks structure: <?php namespace App\Providers; use Roots\Acorn\Sage\SageServiceProvider; class RewriteRulesServiceProvider extends SageServiceProvider { public function boot() { // Add rewrite rule for /search // Add 'search' to the query vars return $vars; // Redirect /search to search template public function addRewriteRules() { add_rewrite_rule( add_rewrite_rule( add_rewrite_rule( add_rewrite_rule( add_rewrite_rule( add_rewrite_rule( add_rewrite_rule( add_rewrite_rule( public function customPostTypeLink( $post_link, $post ) { if ( $post->post_type == 'office' ) { return home_url( 'global-immigration/market/' . $market_post->post_name . '/' . $post->post_name ); if ( $post->post_type == 'team' ) { return home_url( 'global-immigration/market/' . $market_post->post_name . '/' . $office_post->post_name . '/' . $post->post_name ); if ( $post->post_type == 'visa' ) { if ( $related_post ) { return $post_link; |
September 24, 2024 at 3:17 am #16212253 | |
Andreas W. Supporter Languages: English (English ) Spanish (Español ) German (Deutsch ) Timezone: America/Lima (GMT-05:00) |
Hello, If we are talking about the product archive slug, then translating it with String Translation would be the correct way. Did you try this already? I would like to take a closer look into this issue. I can offer to have a closer look at the site as an admin or provide a test site with WPML on which you can recreate the issue by installing your theme and the necessary plugins so that I can assist you on this matter. Which way would you prefer? Best regards |
September 24, 2024 at 8:33 am #16212963 | |
davidH-179 |
yes you can be admin, how should I send the details? |
September 24, 2024 at 11:33 am #16214280 | |
Andreas W. Supporter Languages: English (English ) Spanish (Español ) German (Deutsch ) Timezone: America/Lima (GMT-05:00) |
Hello, I would like to offer to have a closer look at the problem and request temporary access (wp-admin and FTP) to the website to investigate this issue further. You can find the required fields below the comment section when you log in to leave the next reply. The information you provide is private, which means only you and I can see and access it. IMPORTANT I may have to install a plugin called "All In One WP Migration" to make a copy of the website where I can investigate the issue further. However, I would also be very grateful if you could provide a staging site or copy of the website from your server yourself for this purpose. This step would only be required if the issue is replicable on such a staging site. If you have any questions about creating such a staging site, you can consult your hosting provider. Just take note that WPML should be registered on this site again. If you are unable to provide such a copy of the site for testing, please let me know on this ticket. The private response form looks like this: Next time you reply, click "I still need assistance." Video: Please note that we are obliged to request this information individually on each ticket. We may not access any access information not specifically submitted on this ticket in the private response form. Best regards |
September 24, 2024 at 1:20 pm #16215166 | |
davidH-179 |
And this is a general site password you will need : cqc7kdy9ayz*mcu-TBA |
September 24, 2024 at 2:37 pm #16215635 | |
davidH-179 |
? |
September 24, 2024 at 2:37 pm #16215636 | |
davidH-179 |
? did you receive |
September 24, 2024 at 2:42 pm #16215642 | |
Andreas W. Supporter Languages: English (English ) Spanish (Español ) German (Deutsch ) Timezone: America/Lima (GMT-05:00) |
Yes, I am looking into this in a moment. |
September 24, 2024 at 3:02 pm #16215815 | |
davidH-179 |
Ok thank you |
September 24, 2024 at 9:40 pm #16217655 | |
Andreas W. Supporter Languages: English (English ) Spanish (Español ) German (Deutsch ) Timezone: America/Lima (GMT-05:00) |
I can see translated CPTs here: And here: I enable the slug translation inside the WPML settings. You can translate slugs for these post types not at WPML > Setttings > Post Type Translation. See screenshots. |
September 27, 2024 at 9:50 am #16229270 | |
davidH-179 |
Thanks, thats helped I think, most of the pages are translating well. But the below type of pages are not working. When I use the language switcher it does not change to chinese... Office pages: Market Pages Bio pages |
September 27, 2024 at 9:59 am #16229308 | |
davidH-179 |
And visa pages: |
September 27, 2024 at 1:15 pm #16230016 | |
davidH-179 |
Is it possible to get assistance on this, we are launching this site on Monday. In addition to the above there are a couple of other small things that I'd like you to look at like the breadcrumbs are not translating either |