wordpress-seo icon indicating copy to clipboard operation
wordpress-seo copied to clipboard

<lastmod> date is wrong in sitemap

Open rscs opened this issue 12 years ago • 5 comments

I'm using v1.5.3.2. I noticed when testing a sitemap for a client, the Last Modified date of her pages was incorrect. A little digging into inc/class-sitemaps.php revealed a few missing parenthesis. This fixed my problem.

$url['mod'] = ( isset( $p->post_modified_gmt ) && $p->post_modified_gmt != '0000-00-00 00:00:00' && $p->post_modified_gmt > $p->post_date_gmt ) ? $p->post_modified_gmt : ( '0000-00-00 00:00:00' != $p->post_date_gmt ) ? $p->post_date_gmt : $p->post_date;

Should be changed to:

$url['mod'] = ( isset( $p->post_modified_gmt ) && $p->post_modified_gmt != '0000-00-00 00:00:00' && $p->post_modified_gmt > $p->post_date_gmt ) ? $p->post_modified_gmt : ( ( '0000-00-00 00:00:00' != $p->post_date_gmt ) ? $p->post_date_gmt : $p->post_date );

rscs avatar May 17 '14 16:05 rscs

sitemap_bug

webmastertools_error

I found this same issue when google was showing an error about lastmod on line 41. There is no line 41, and checking inside the files looks fine, but as you can see from the attachment, there is no date for one of the sitemaps.

I attempted the change noted above but does not solve the issue I am having.

shawnlunny avatar May 19 '14 05:05 shawnlunny

I am seeing the same thing. Last Modified date appears to be injecting the Published date instead of the actual last edited date.

nakitadog avatar May 19 '14 14:05 nakitadog

The fix that rscs proposed worked for me as well.

nakitadog avatar May 19 '14 15:05 nakitadog

I did a comparison against my sitemap before and after v1.5.3.2 and noticed all my dates were wrong as well. Your fix worked for me as well.

bridgeport avatar May 20 '14 15:05 bridgeport

I've created pull request #1161 with your suggested fix. Closing this issue in favour of the pull request.

jrfnl avatar May 23 '14 03:05 jrfnl