<?xml version="1.0" encoding="utf-8"?>
<urlset>
<url>
<loc>https://XXXXX.com</loc>
<lastmod>{dede:arclist row=1 titlelen=24 orderby=pubdate}
[field:pubdate function='strftime("%Y-%m-%d %H:%M:%S",@me)'/]
{/dede:arclist}</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
{dede:channel typeid='栏目ID' type='son'}
<url>
<loc>https://XXXXX.com[field:typelink /]</loc>
<lastmod>[field:typelink function='newtime()'/]</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
{/dede:channel}
<!--多个栏目ID多次添加-->
{dede:arclist row=30 orderby=pubdate}
<url>
<loc>https://XXXXX.com[field:arcurl/]</loc>
<lastmod>[field:pubdate function='strftime("%Y-%m-%d %H:%M:%S",@me)'/]</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
{/dede:arclist}
</urlset>
其中难点在于栏目页面的时间设置,这里通过自定义函数newtime()来返回最新一篇文章的入库时间来作为栏目的时间newtime()代码如下:
function newtime() {
global $dsql;
$row = $dsql->GetOne("SELECT senddate FROM dede_archives WHERE id = (SELECT MAX(id) FROM dede_archives)");
return date("Y-m-d H:i:s", $row['senddate']);;
}
上面代码添加到inc/extend.func.php中