[Plugin: WordPress SEO by Yoast] Invalid url loc in sitemaps
-
I’ve noticed some URL’s in our sitemap weren’t generated correctly.
Some of them had the site_url missing, which causes errors in Google’s Webmaster Tools and probably other parsers too.This happens for both post type and images.
Where a url should have<loc>https://domain.com/wpfolder/sub/some-post.html</loc>
There was
<loc>/wpfolder/sub/some-post.html</loc>
I’ve solved this in the class-sitemaps.php
At line +-500, replace:$output .= "\t\t<loc>".$url['loc']."</loc>\n";
with
if ( strpos($url['loc'], 'http') === false ) $output .= "\t\t<loc>".home_url($url['loc'])."</loc>\n"; else $output .= "\t\t<loc>".$url['loc']."</loc>\n";
The same goes for the image:loc a bit below.
I’m not sure what causes this, might be with the statement at line 338:
if ( strpos($src, 'http') !== 0 )
should be compared to false instead 0 ?
–coati
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘[Plugin: WordPress SEO by Yoast] Invalid url loc in sitemaps’ is closed to new replies.