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

作者: 站长 上传时间: 浏览: N/A 下载: N/A 格式: N/A 评分: N/A

如何解决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 / 中加入以下代码


rewrite ^/sitemap.xml$ /sitemap.php last;

Leave a Comment