废话不多说,直接上代码
复制代码代码如下:
require('./wp-blog-header.php');
header("Content-type: text/xml");
header('HTTP/1.1 200 OK');
$posts_to_show = 1000; // 获取文章数量
echo '';
echo '
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 '" rel="external nofollow" >http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">';
?>
header("Content-type: text/xml");
$myposts = get_posts( "numberposts=" . $posts_to_show );
foreach( $myposts as $post ) { ?>
复制上面代码为xmlmap.php文件并传至网站根目录
http://localhost/xmlmap.php