Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client is using the directory for the default language, and the SEO Framework is incorrectly adding this default language directory to all sitemap links in robots.txt, resulting in invalid URLs.
Solution:
We recommend modifying the SEO Framework plugin code to correct the sitemap URLs:
1. Open the file located at

.../wp-content/plugins/autodescription/inc/classes/sitemap/registry.class.php

.
2. Locate line 173.
3. Replace the line with:

$path_info = static::get_sitemap_base_path_info();

with:

$path_info = static::get_sitemap_base_path_info();<br />// Workaround for compsupp-7598<br />if ( $_SERVER['REQUEST_URI'] == 'https://cdn.wpml.org/robots.txt' ) {<br />    $wpml_language_directory = apply_filters('wpml_get_setting', false, 'urls')['directory_for_default_language'];<br />    if ( $id != 'base' && $wpml_language_directory && $list['base']['robots'] )  {<br />        $path_info['path'] = '/';<br />    }<br />}

Please note this is a temporary workaround. We are awaiting a more comprehensive solution from the plugin author.

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 at WPML support forum.

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.

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by Bruno Kos 8 months, 1 week ago.

Assisted by: Bruno Kos.

Author Posts
September 19, 2024 at 10:00 am #16197619

dawidZ-5

Background of the issue:
I use the directory for the default language, and the SEO Framework adds this default language directory to all sitemaps links for the rest of the languages inside robots.txt. My robots.txt: Sitemap: hidden link Sitemap: hidden link Sitemap: hidden link Sitemap: hidden link Sitemap: hidden link Sitemap: hidden link Sitemap: hidden link Sitemap: hidden link Sitemap: hidden link Sitemap: hidden link Sitemap: hidden link Sitemap: hidden link

Symptoms:
The SEO Framework generates invalid URLs for the sitemap in robots.txt.

Questions:
Why is the SEO Framework adding the default language directory to all sitemap links?
How can I configure the SEO Framework to generate correct sitemap URLs for each language?

September 19, 2024 at 11:32 am #16198269

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 if you see the issue here?
hidden link

Because this is what I get for sitemap URLs:
hidden link
hidden link

September 19, 2024 at 4:36 pm #16200282

dawidZ-5

Yes, the problem still exists,
hidden link
in the robots.txt file link to de language sitemap is incorrect
Sitemap: hidden link

there is added /en/ before /de/

There is no problem with generating the actual site map, there is a problem with adding the correct link to the site map in the robots.txt file for translated languages

September 20, 2024 at 8:52 am #16201687

Bruno Kos
WPML Supporter since 12/2018

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

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

I escalated this case to our Compatibility team and will keep you posted.

September 24, 2024 at 12:51 pm #16215014

Bruno Kos
WPML Supporter since 12/2018

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

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

Can you please try the following:

1. Open the `.../wp-content/plugins/autodescription/inc/classes/sitemap/registry.class.php` file.

2. Locate line 173.

3. Replace the following line:

  $path_info = static::get_sitemap_base_path_info();

With this updated code:

   $path_info = static::get_sitemap_base_path_info();

   // Workaround for compsupp-7598
   $wpml_language_directory = apply_filters('wpml_get_setting', false, 'urls')['directory_for_default_language'];
   if ( $id != 'base' AND $wpml_language_directory )  {
       $path_info['path'] = '/';
   }

Does it work?

September 25, 2024 at 9:10 am #16219174

dawidZ-5

Hi,
after updating this code sitemap.xml is returning 404

Zrzut ekranu 2024-09-25 110959.png
September 25, 2024 at 9:24 am #16219375

Bruno Kos
WPML Supporter since 12/2018

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

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

Let me check this with Compatibility team.

September 26, 2024 at 11:26 am #16224742

Bruno Kos
WPML Supporter since 12/2018

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

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

We’ve made a small adjustment to the workaround. Could you please try it again?

1. Open the file located at: `.../wp-content/plugins/autodescription/inc/classes/sitemap/registry.class.php`.
2. Locate line 173.
3. Replace the following line:

$path_info = static::get_sitemap_base_path_info();

With this:

$path_info = static::get_sitemap_base_path_info();

// Workaround for compsupp-7598
if ( $_SERVER['REQUEST_URI'] == 'https://cdn.wpml.org/robots.txt' ) {
    $wpml_language_directory = apply_filters('wpml_get_setting', false, 'urls')['directory_for_default_language'];
    if ( $id != 'base' && $wpml_language_directory && $list['base']['robots'] )  {
        $path_info['path'] = '/';
    }
}

Please note that this is just a temporary workaround. We'll still need input from the plugin author to implement a more comprehensive solution, as they are responsible for the compatibility updates.

Let me know if this works!