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
- 8:00 – 13:00 9:00 – 13:00 9:00 – 13:00 8:00 – 12:00 8:00 – 12:00 -
- 14:00 – 17:00 14:00 – 18:00 14:00 – 18:00 13:00 – 17:00 13:00 – 17:00 -

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

Tagged: 

This topic contains 1 replies, has 2 voices.

Last updated by Bruno Kos 7 months ago.

Assisted by: Bruno Kos.

Author Posts
October 22, 2024 at 11:26 am #16317035

adiP-4

Background of the issue:
I am trying to use WPML and YoastSEO with the integration plugin (wp-seo-multilingual) to manage languages on my website. When I add a new language, all archives for this language are immediately added to the sitemap. I managed to remove the archives using some filters, but this should be fixed.
The issue seems to be coming from the file: 'wp-seo-multilingual/classes/class-wpml-wpseo-xml-sitemaps-filter.php'. To reproduce, simply add a new language to the website. Then, without translating any content, you will see the archives for all posts types in this language added to the sitemaps created by Yoast. Additionally, going to these archives will return a 200 (this is probably a different issue).

Symptoms:
When a new language is added, all archives for that language are added to the sitemap, even if there is no content. This includes the blog and all CPT's. Empty archives are indexed by Google without warning, which is not expected.

Questions:
Why are all archives added to the sitemap when a new language is added?
How can I prevent empty archives from being indexed by Google?

October 22, 2024 at 11:43 am #16317158

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

Can you tell me which filters have you tried? Something like this?

add_filter( 'wpseo_sitemap_entry', 'remove_empty_archives_from_sitemap', 10, 3 );
function remove_empty_archives_from_sitemap( $url, $type, $post ) {
    if ( is_archive() && ! have_posts() ) {
        return false; // Don't include this archive in the sitemap if there are no posts.
    }
    return $url;
}

Or this to exclude these from Google?

add_filter( 'wpseo_robots', 'noindex_empty_archives' );
function noindex_empty_archives( $robots ) {
    if ( is_archive() && ! have_posts() ) {
        return 'noindex,follow'; // Add noindex for archives with no posts.
    }
    return $robots;
}

The topic ‘[Closed] Adding a language to the website immediately adds all archives to the sitemap’ is closed to new replies.