wordpress非插件实现xml格式网站地图

废话不多说,直接上代码

复制代码
代码如下:

require('./wp-blog-header.php');
header("Content-type: text/xml");
header('HTTP/1.1 200 OK');
$posts_to_show = 1000; // 获取文章数量
echo '';
echo 'http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 '" rel="external nofollow" >http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">';
?>


http://localhost/

daily
1.0

header("Content-type: text/xml");
$myposts = get_posts( "numberposts=" . $posts_to_show );
foreach( $myposts as $post ) { ?>



monthly
0.6



复制上面代码为xmlmap.php文件并传至网站根目录
http://localhost/xmlmap.php

你可能感兴趣的:(wordpress非插件实现xml格式网站地图)