This Solution is about how to avoid duplicate urls on xml sitemap video wordpress. The problem is when we’ve multiple videos on the same post, I’m using this plugin Google XML Sitemap for Videos and it’s great but it’s generating multiple entries with the same url and google is detecting these errors.
To avoid that we need to edit (2 steps) this plugin and add these lines:
1-.
Search:
$xml .= ‘< ?xml-stylesheet type=”text/xsl” href=”‘ . get_bloginfo(‘wpurl’) . ‘/wp-content/plugins/xml-sitemaps-for-videos/video-sitemap.xsl”?>’ . “\n” ;
$xml .= ” . “\n”;
$videos = array();
Add:
$permalink_array = array();
Finally:
$xml .= ‘< ?xml-stylesheet type=”text/xsl” href=”‘ . get_bloginfo(‘wpurl’) . ‘/wp-content/plugins/xml-sitemaps-for-videos/video-sitemap.xsl”?>’ . “\n” ;
$xml .= ” . “\n”;
$videos = array();
$permalink_array = array();
2-.
Search:
$id = $match [2];
$fix = $c++==0?”:’ [Video '. $c .'] ‘;
if (in_array($id, $videos))
continue;
Add:
if (array_key_exists($permalink,$permalink_array))
continue;
$permalink_array[$permalink];
Finally:
$id = $match [2];
$fix = $c++==0?”:’ [Video '. $c .'] ‘;
if (in_array($id, $videos))
continue;
if (array_key_exists($permalink,$permalink_array))
continue;
$permalink_array[$permalink];
We need to save and re-generate our video sitemap and that’s it!
With this solution we will only have unique urls in our video sitemap.



Comentarios recientes