Resolved
Resolved in: WPML 4.9
Overview of the issue
When you have a custom product base set to e.g. “/catalogue/%post_id%/” in Settings > Permalinks in WordPress, and you translate that base, you might encounter an error 404 (Not found) for the translated products
Workaround
Go to: /wp-content/plugins/wpml-string-translation/classes/slug-translation/new-match-finder/wpml-st-slug-new-match-finder.php
There in the function:filter_slug_using_tag, just after this exact code:
private function filter_slug_using_tag( $slug ) {
add this new code:
if ( preg_match( '#%post_id%#', $slug ) ) {
$slug = preg_replace( '#%post_id%#', '([0-9]+)', $slug );
}
Hi, the main language of our site is English. Translations are Dutch and German. There was a 404 error on the translation of the products and categories. I added the new code and now the products are shown in Dutch in German. However, there are still 404 errors on the categories. How do I solve this?
Hi Bas,
The code provided allows numerical values for the tag %post_id%. Since you’re experiencing the issue with categories, you might need to apply a similar approach to allow any numerical values in your category base.
If you need further assistance, feel free to start a chat on our support forum, we’ll be happy to help!