这篇文章主要介绍了wordpress非插件实现xml格式网站地图,需要的朋友可以参考下

废话不多说,直接上代码

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”>’;
?>


http://localhost/

daily1.0

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



monthly0.6


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

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。