纯代码实现wordpress5.8+可用sitemap.xml文件

  

如何解决sitemap.xml报以下错误
post,sitemap,sitemap.xml,wordpress,xml,代码,博客,可用,实现,文件,纯代码,网站,解决,页面,纯代码实现wordpress5.8+可用sitemap.xml文件

1、将以下代码保存为sitemap.php放入wordpress网站根目录

';
echo '';
require('./wp-blog-header.php');
header("Content-type: text/xml");
header('HTTP/1.1 200 OK');
$posts_to_show =300;
?>




daily 1.0





monthly 0.7





monthly 0.7


0) {
foreach($mypages as $page) { ?>

ID); ?>
ID)->post_modified); ?>
monthly 0.6


ID); ?>

ID)->post_modified); ?>
monthly 0.5


0){
foreach ($terms as $term) { ?>

slug); ?>
monthly 0.6


slug); ?>

weekly 0.8



2、修改网站的nginx配置文件server段,location / 中加入以下代码

post,sitemap,sitemap.xml,wordpress,xml,代码,博客,可用,实现,文件,纯代码,网站,解决,页面,纯代码实现wordpress5.8+可用sitemap.xml文件
rewrite ^/sitemap.xml$ /sitemap.php last;

您必须才能评论!