Hello,
We apologize for the critical issue you are facing with the Remove Base option in conjunction with WPML. Thank you for bringing this concern to our attention.
It seems that enabling the Remove Base toggle is causing broken URLs when switching languages on translated product pages. This is indeed a significant issue, and we appreciate your detailed steps to reproduce it, as well as the links to the WPML forum discussions.
While we currently do not have a specific solution for this issue in our documentation, we recommend replying to this ticket. A human agent from the Rank Math Support team will take over and provide further assistance regarding this compatibility problem with WPML.
Thank you for your patience as we work to resolve this matter. If you have any more details or updates, please feel free to share them here.
Hello,
Thank you for contacting us and sorry for any inconvenience that this issue might have caused.
To attempt to resolve this issue, consider installing the WPML SEO glue extension:
https://wpml.org/compatibility/2021/04/wpml-seo-plugin-better-integration-with-seo-plugins/
Please note that when you enable the Strip Category Base option in Rank Math → General Settings and translate the taxonomy slug in WPML → Taxonomy Translation, the translated archive page displays a 404 error. The same happens for the “Remove Base” option for products (Rank Math → General Settings → WooCommerce).
As a workaround do not translate the category, product, or product-category slugs. The untranslated terms won’t be visible in the URL anyway when you use any of those options.
See: https://wpml.org/errata/rank-math-seo-turning-on-strip-category-base-causes-issues-with-secondary-languages/
Let us know how this goes. Also, let us know if you have further questions or concerns.
Thank you.
I am not sure I understand as this seems like a copy paste response and a little irrelevant to our goals. Let me explain:
We are NOT interested in removing the category base; this is vital for SEO and does in fact work just fine with WPML when RankMath is not installed. This is NOT our goal
Our ONLY goal is to remove “/shop/” from the url. So with this in mind would we need to prevent the translation of /shop/ and/or revert it?
How should we do that?
Please note /shop/ is not currently translated. Please escalate this ASAP. WPML will also be reaching out: https://imgur.com/a/mT64gF6
Hello,
We deeply apologize for the delay.
We have shared this ticket with our development team. If there is any progress, we will let you know here.
Appreciate your time and patience in the meantime.
Hello,
When the Remove Product Base option is enabled, the Rank Math plugin redirects the old URL with the product base to the new one. This redirection code is not working well with the multi-domain option of WPML. For now, to fix the issue on your site I have disabled the Product Redirection by adding following filter code in your theme’s functions.php file:
add_filter('rank_math/woocommerce/product_redirection', '__return_false');
This seems to have fixed the issue. Could you please confirm?
The code provided by the WPML team did not resolve the issue on your site. Would it be possible for you to share FTP access to your site so we can make changes to the plugin code to debug this further? It would be even better if you could create a staging site.
Hope this helps.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Hi Pratik, thank you for the update. Yes, WPML has published an errata regarding the issue although their “solution” does not work in our case: https://wpml.org/errata/rank-math-seo-urls-with-special-characters-lead-to-404-errors/. As you can tell we are at Day 47 and they have no relevant solution for us. Please note there were 3x scenarios in which we were using to evaluate a resolution:
1.] NOT RESOLVED: Go to https://es.ellasbubbles.com/, scroll down, and click on a product. I try clicking on Petite/Royal/Elite and get brought to the English version of the site for 2x of these examples and get brought to a 404 error for the other: https://ellasbubbles.com/page-not-found/#main
2.] RESOLVED: Try browsing the main English website, casually visit (https://ellasbubbles.com/walk-in-tubs/stainless-steel-door/royal/). Now shift your language back to Spanish. 404 ERORR (https://ellasbubbles.com/page-not-found/)
3.] NOT RESOLVED: Try a completely difference language (https://fr.ellasbubbles.ca/). Maybe access a category page (https://fr.ellasbubbles.ca/baignoires-sans-rendez-vous-de-la-marque-ella/baignoires-de-table-en-acrylique/). Click on a product from that category (https://ellasbubbles.com/walk-in-tubs/lay-down/32×72/). Transferred Back to English
I will be editing the Sensitive Data now in the next 5 minutes with access to our CP
Hello,
I logged into your site and changed the following code on line 133 in includes/modules/woocommerce/class-product-redirection.php
Replaced: 2 === (int) $sitepress_settings['custom_posts_sync_option']['product']
With: 0 !== (int) $sitepress_settings['custom_posts_sync_option']['product']
This seem to have fixed the issue. Could you please confirm?
Hope that helps.
Thank you, although I believe WPML is in contact with your devs for a fix now. Can you please check on this? Here is the solution they had sent me:
——
What needs to be adjusted if RankMath is updated is detailed here.
https://wpml.org/errata/rank-math-seo-remove-base-option-causes-redirection-issues/
When the fix is included in the Rank Math SEO plugin, we will change this page’s status to Resolved, and then the adjustment will no longer be needed. For your convenience, I have included the details here.
Please, make sure of having a full site backup of your site before proceeding.
1. Open …/wp-content/plugins/seo-by-rank-math/includes/modules/woocommerce/class-product-redirection.php file.
2. Look for line 139.
3. Replace:
1
$link = trim( str_replace( Helper::get_home_url(), ”, get_permalink() ), ‘/’ );
With:
1
2
3
4
5
6
7
8
9
10
11
// WPML – Workaround for compsupp-7311
$home_url = Helper::get_home_url();
if (
Sitepress::get()->is_active() &&
$sitepress_settings[‘language_negotiation_type’] == 2
) {
$home_url = get_home_url();
}
$link = trim( str_replace( $home_url, ”, get_permalink() ), ‘/’ );
4. Save the file.
**** Important! Please make a full site backup (files and DB) before you proceed with those steps****
Hello,
We are already in touch with the WPML team. The solution they suggested didn’t work for us, so we are going to share with them the solution we applied to your site, which I mentioned in the previous reply. Could you please confirm if the solution we applied to your site has fixed the issue?
Hope that helps.
Here is their reply to me. Yes the site is resolved. I am not sure if this is because of them, or because of you
Hi,
We have resolved the issue by making modifications to the Rank Math plugin. It’s unclear if the resolution came from the changes suggested by Rank Math’s support or from the modifications we implemented before their suggestion.
Ultimately, it’s up to the developers of Rank Math to determine which fix will be officially implemented in their plugin and when this fix will be released. For now, the solution we’ve applied is confirmed to work. However, you may also consider trying the fix the plugin’s authors recommended as an alternative.
Regards,
Itamar.
Hello,
We appreciate your patience.
We’ll include our changes in tomorrow’s beta update, and then you can confirm if the changes we made alone fixed the issue.
We really look forward to hearing back from you.
Thank you Uzair, please let me know when this is published and I will test immediately
Hello,
You can keep an eye on the changelog of our beta updates here: https://rankmath.com/changelog/beta/.
Hope that helps, and please do not hesitate to let us know if you need our assistance with anything else.