Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Europe/Tirane (GMT+02:00)

This topic contains 1 reply, has 2 voices.

Last updated by Marsel Nikolli 1 year, 1 month ago.

Assisted by: Marsel Nikolli.

Author Posts
March 15, 2024 at 10:26 am #15413831

LukaszM-21

Hi there,

I am trying to figure it out what's wrong. I would like to have a few sitemaps per language, not just one mail with all urls.

So far I have updated my function.php:

add_filter('wpseo_posts_join', 'sitemap_per_language', 10, 2);
function sitemap_per_language($join, $type) {
global $wpdb, $sitepress;

if (isset($sitepress)) {
$lang = $sitepress->get_current_language();
return " JOIN " . $wpdb->prefix . "icl_translations ON element_id = ID AND element_type = 'post_$type' AND language_code = '$lang'";
}

return $join;
}

results:
*/sitemap_index.xml works
*/lang/sitemap_index.xml 404

when turn off WPML SEO
*/sitemap_index.xml works
*/lang/sitemap_index.xml works

there is something with WPML SEO addon that effect it.

March 15, 2024 at 11:32 am #15414089

Marsel Nikolli

Hi,

Thank you for contacting WPML Support, I will gladly help you.

When reviewing your sitemap I can see it's showing for ES and PL

hidden link
hidden link

However, that is not the expected behavior.

Your sitemap should show all languages under 1 sitemap, the only time you should get a different sitemap per language is if you are using a different domain per language.

https://wpml.org/documentation/plugins-compatibility/using-wordpress-seo-with-wpml/#translate-sitemaps

See our sitemap here as an example:
https://wpml.org/page-sitemap.xml

I suggest verifying you are using the latest versions of Yoast SEO, WPML, and WPML SEO

Then do a manual sitemap update, by disabling the sitemap feature, clearing the cache, and enabling the sitemap feature to force the sitemap to rebuild.

---

Regarding the code you provided, please note that custom coding is beyond the scope of this support forum, we recommend that you check our contractors' page: https://wpml.org/contractors/.

Thank you for understanding and I hope you find this information helpful.

Let me know if you have any more questions.

Kind regards,
Marsel

The topic ‘[Closed] WPML SEO addon blocks sitemap per language’ is closed to new replies.