Support Forum

YOAST Sitemap invalid date format

PM Patrick Moering
Patrick Moering
Member

I’m using YOAST together with the sp sitemap plugin to generate sitemaps. While the sitemap itself is valid, the date on the main sitemap (sitemap_index.xml) which is generated by the sp plugin is not valid. I was able to fix this in the plugin code (sp-google-sitemap-components.php line 59):

Before:

$base = $GLOBALS['wp_rewrite']->using_index_permalinks() ? 'index.php/' : '';
 $date = spdb_table(SFPOSTS, '', 'post_date', 'post_date DESC', '1');
 $map.= '<sitemap>';
 $map.= '<loc>'.home_url($base.'forum-sitemap.xml').'</loc>';
 $map.= '<lastmod>'.htmlspecialchars($date).'</lastmod>';

After:

$base = $GLOBALS['wp_rewrite']->using_index_permalinks() ? 'index.php/' : '';
 $date = spdb_table(SFPOSTS, '', 'UNIX_TIMESTAMP(post_date)', 'post_date DESC', '1');
 $map.= '<sitemap>';
 $map.= '<loc>'.home_url($base.'forum-sitemap.xml').'</loc>';
 $map.= '<lastmod>'.htmlspecialchars(date('c', $date)).'</lastmod>';

6 Answers

New Answer

MP Mr Papa
Mr Papa
Member

Interesting.. Is this one big huge site map vice multiple sub maps…

Will have to research why this one does not have a timestamp convert.  Curious no reports but most use sub maps…

Thanks for the info….

PM Patrick Moering
Patrick Moering
Member

Google webmaster tools reported the invalid timestamp but also was able to recognize the correct date. I can’t tell you if the report has any disadvantages.

PM Patrick Moering
Patrick Moering
Member

Thanks for the plugin update, however it did not fix the problem. Now it just prints an unformatted timestamp since this part is missing:

date('c', $date)
YS Yellow Swordfish
Yellow Swordfish
Member

Oh dear – bad timing! Mr Papa is away for a couple of days. 

I know he made some change last week. are you saying that you know what to do t get this how you mneed it? If so I would suggest you make the change and Mr Papa will get in touch as soon as he returns.

MP Mr Papa
Mr Papa
Member

argh…  tested my change, but seems a second change needed further up stream… will try to get an update out here today or tomorrow…  sorry…