[Resolved] Product archive slug translation problem
This thread is resolved. Here is a description of the problem and solution.
Problem: When using SEOPress plugin with WPML, the product archive slugs are not correctly translated in the XML sitemaps generated by SEOPress.
Solution: We have acknowledged the issue with SEO Press not correctly handling translated slugs in sitemaps. We recommend checking the following errata for a workaround and subscribing to the comments on our errata page for this specific issue to stay updated on future fixes: https://wpml.org/errata/seopress-product-archive-slug-not-translated-in-sitemaps/.
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. If the problem persists, please open a new support ticket with us for further assistance.
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.
Thank you for your patience and cooperation. Our team has debugged the issue and have provided the following temporary workaround:
- Take full backup of your site and database.
- Open app/public/wp-content/plugins/wp-seopress/templates/sitemap/single.php file for editing.
- Look for the following snippet, around line 41:
// WPML Workaround
if (class_exists('SitePress')) {
if ( 2 != apply_filters( 'wpml_setting', false, 'language_negotiation_type' ) ) {
$original_language = apply_filters( 'wpml_current_language', NULL );
$language_list = apply_filters( 'wpml_active_languages', NULL, 'orderby=id&order=desc' );
if (!empty($language_list)) {
foreach ($language_list as $key => $language_infos ) {
if ($original_language != $language_infos['language_code']) {
// Switch Language
do_action( 'wpml_switch_language', $language_infos['language_code']);
$archive_links[] = htmlspecialchars(urldecode(user_trailingslashit(get_post_type_archive_link($path))));
// Restore language to the original
do_action( 'wpml_switch_language', $original_language);
}
}
}
}
- Replace with:
// WPML Workaround for compsupp-7538 and compsupp-6419
if ( class_exists('SitePress' )) {
if ( 2 != apply_filters( 'wpml_setting', false, 'language_negotiation_type' ) ) {
$original_language = apply_filters( 'wpml_current_language', NULL );
$language_list = apply_filters( 'wpml_active_languages', NULL, 'orderby=id&order=desc' );
if (!empty($language_list)) {
foreach ($language_list as $key => $language_infos ) {
if ($original_language != $language_infos['language_code']) {
// Switch Language
do_action( 'wpml_switch_language', $language_infos['language_code']);
if ( $path == 'product' && function_exists('wc_get_page_id') ) {
$shop_page_id = wc_get_page_id('shop');
$archive_links[] = htmlspecialchars(urldecode(user_trailingslashit(get_permalink($shop_page_id))));
} else {
$archive_links[] = htmlspecialchars(urldecode(user_trailingslashit(get_post_type_archive_link($path))));
}
// Restore language to the original
do_action( 'wpml_switch_language', $original_language);
}
}
}
}
}
- Save the file and recheck.
I've tried this in the sandbox site (hidden link) and it seems to work fine.
Please let me know after applying and checking the above mentioned.
Thank you for confirming and glad it worked for you too.
Yes when plugin is updated, that'd be deleted. However, whenever there's a new update of the plugin, please keep following in mind:
- Take a backup before update.
- Keep this ticket bookmarked or save the solution to a suitable place.
So after updating if issue returns, you can compare if it was rolled out or not and you can act accordingly.
Usually, for such issues our team publishes an erratum, which you can follow to observe the release of the fix. I'll let you know as soon as the erratum is published.