Skip to content Skip to sidebar

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.

This topic contains 21 replies, has 2 voices.

Last updated by Waqas Bin Hasan 11 months, 2 weeks ago.

Assisted by: Waqas Bin Hasan.

Author Posts
August 20, 2024 at 6:17 am #16085697

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your patience and cooperation.

I was able to reproduce the problem in a fresh setup and 've escalated the matter to our compatibility team for investigation.

I'll get back to you accordingly.

August 22, 2024 at 9:34 am #16093819

alexanderS-177

Is there any news?

August 22, 2024 at 12:53 pm #16095034

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

The matter is still with our compatibility team. I'm checking about it. Please accept our apologies for the delay due to some load in the queue.

I'll update you as soon as I hear back.

Thank you for your patience and cooperation.

August 27, 2024 at 8:45 am #16108336

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

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.

Screenshot 2024-08-27 134112.jpg
August 29, 2024 at 12:48 pm #16120031

alexanderS-177

Thank you very much. It's working.
However, won't this be deleted once we update the plugin?

August 30, 2024 at 6:25 am #16122897

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

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.

August 30, 2024 at 8:42 am #16123729

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Our team has published the errata at https://wpml.org/errata/seopress-product-archive-slug-not-translated-in-sitemaps/. Please subscribe to the comments on this errata for future updates.