Forums

[Plugin: Google XML Sitemaps] Code for using comment date for last modified in 3.1.6 (1 post)

  1. natethelen
    Member
    Posted 1 month ago #

    I replaced lines 1954-1955 in sitemap-core.php to the following so that it will use the latest comment date as the last modified date if it is newer than the post's last modified date. One caveat: I am using memcached with wordpress so most of these comment queries are cached and do not go to the database.

    $lastModifiedDate = $this->GetTimestampFromMySql(($post->post_modified_gmt && $post->post_modified_gmt!='0000-00-00 00:00:00'?$post->post_modified_gmt:$post->post_date_gmt));
    $latestComment = get_comments('post_id='. $post->ID .'&number=1');
    if(count($latestComment)) {
    	$latestCommentDate = $this->GetTimestampFromMySql($latestComment[0]->comment_date_gmt);
    	if($latestCommentDate > $lastModifiedDate) {
    		$lastModifiedDate = $latestCommentDate;
    	}
    }
    
    //Add it
    $this->AddUrl($permalink,$lastModifiedDate,($isPage?$cf_pages:$cf_posts),$prio);

Reply

You must log in to post.

About this Topic

  • RSS feed for this topic
  • Started 1 month ago by natethelen
  • WordPress version: 2.8.4
  • This topic is not a support question