修改插件Smart SEO Tool网站地图生成功能 修改最后修改时间为发布时间
- 对于 http://www.xxx..com/sitemap.xml,网站地图首页不做修改,仍调用最后修改时间,若调用最新发布时间,子 Sitemap 地址文章的链接时间会出现 1990-01-01 00:00。
- 对于 http://www.xxx..com/sitemap-post-xxx.xml,需修改成文章定时发布的时间。
修改前代码:
private static function content_post($post_type, $param)
{
// global $wpdb;
$blog_update = get_lastpostdate('blog');
$cnf = self::cnf('sitemap_seo.content_item.' . $post_type);
$group_type = self::cnf('sitemap_seo.data_group');
$xml = '';
$where = '';
$db = self::db();
//print_r([$post_type,$param]);
$limit = '';
$order = 'DESC';
if ($param) {
if (preg_match('#^(\d+)-(\d+)$#', $param, $m)) {
$year = $m[1];
$offset = $m[2] * self::$pagesize;
$limit = ' LIMIT ' . $offset . ',' . self::$pagesize;
} else {
if ($group_type == 'data' && preg_match('#^\d+$#', $param)) {
$per_page_num = self::cnf('sitemap_seo.per_page_num');
$per_page = $per_page_num ? absint($per_page_num) : 1000;
if (!$per_page) $per_page = 1000;
$year = '';
$page = absint($param);
if (!$page) $page = 1;
$offset = ($page - 1) * $per_page;
$limit = " LIMIT $offset,$per_page";
//$order = 'DESC';
} else {
$year = $param;
$limit = ' LIMIT 0,' . self::$pagesize;
}
}
if ($year) {
$where = $db->prepare(" AND YEAR(p.post_date) = %d", $year);
}
}
$sql = "SELECT
p.ID,
p.post_author,
p.post_status,
p.post_name,
p.post_parent,
p.post_type,
p.post_date,
p.post_date_gmt,
p.post_modified,
p.post_modified_gmt,
p.comment_count
FROM
{$db->posts} p
WHERE
p.post_password = ''
AND p.post_type = '%s'
AND p.post_status = 'publish'
$where
ORDER BY
p.post_date $order " . $limit;
$list = $db->get_results($db->prepare($sql, $post_type));
foreach ($list as $post) {
$url = get_permalink($post);
$xml .= self::add_url($url, $post->post_modified, $cnf['frequency'], $cnf['weights']);
}
return $xml;
}
修改后代码:直接替换即可
此处内容需要权限查看
会员免费查看修改完成后样式: