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

Problem: Yoast XML sitemap is showing empty lines

Solution: Empty lines in Yoast XML Sitemap when the secondary languages are set as hidden. This bug is expected to fix in WPML 4.0. As a workaround for the time being please add the following code to *functions.php* of your theme after site backup.

add_filter('wpseo_sitemap_entry', function ($url){
    if (isset($url['loc']) && empty($url['loc'])) {
        return FALSE;
    }
     
    return $url;
});

Relevant Documentation:

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 10 replies, has 2 voices.

Last updated by giuseppeP-25 2 years, 1 month ago.

Assigned support staff: Ricardo Alday.

Author Posts
April 20, 2018 at 10:41 am #1721421

giuseppeP-25

Hello,
I took a look at my website sitemap and it shows some empty lines.
I was wondering if this may depend on the fact that one of two languaes of the website is hidden.

Is that's the problem, is it possibile to fix it?
Thank you

April 23, 2018 at 10:37 pm #1777755

Ricardo Alday

Hiu,

Thanks for contacting support. I'll do my best to help you with your question.
Can you add the following code to *functions.php* of your theme after site backup.

add_filter('wpseo_sitemap_entry', function ($url){
    if (isset($url['loc']) && empty($url['loc'])) {
        return FALSE;
    }
     
    return $url;
});

Let me know if it makes a difference.

Best regards,
Ricardo

April 24, 2018 at 5:42 am #1779398

giuseppeP-25

Dear Ricardo,
I'll tray that, thank you.
I have only a doubt.
Does this depends on the fact that Italian language is hidden?
So, will i have to delete the code as soon as I turn it on?
Thank you

April 24, 2018 at 4:23 pm #1794013

Ricardo Alday

Yes, it usually happens if the language is hidden. So you will need to revert the change when you make the language visible again.

May 7, 2018 at 10:36 am #2008542

giuseppeP-25

Hello,
sorry for late reply. I different functions.php files in my file manager.
like: /public_html/wp-includes/functions.php

/public_html/wp-content/plugins/wpml-string-translation/inc/functions.php

/public_html/wp-content/plugins/wpml-translation-management/inc/translation-proxy/functions.php

...

But the theme is Apicona ... so maybe are you referring to one of these two?
/public_html/wp-content/themes/apicona-child/functions.php

/public_html/wp-content/themes/apicona/functions.php

Please let me know

May 7, 2018 at 3:58 pm #2015846

Ricardo Alday

Put it in the child theme functions.php file:
/public_html/wp-content/themes/apicona-child/functions.php

May 8, 2018 at 2:07 pm #2032874

giuseppeP-25

Hello, everything looks fine.
I have only a problem with a sitemap that gives a 404 error
Is that because I have this pages only in Italian and nothing in English?
Thank you

May 8, 2018 at 6:41 pm #2038556

Ricardo Alday

What's the link to the sitemap that generates the 404 error?

May 9, 2018 at 8:44 am #2047094

giuseppeP-25

Hi there, this is the link hidden link

May 9, 2018 at 5:34 pm #2059049

Ricardo Alday

I'm not sure if that's related to WPML. It may be the way the post type is configured.

Check this article for more information: hidden link

May 17, 2018 at 8:34 am #2170315

giuseppeP-25

Thank you Ricardo! Everything is fine now!