wordpress非插件完成xml格局网站地图

废话不多说,间接上代码


<?php
require('./wp-blog-header.php');
header("Content-type: text/xml");
header('HTTP/1.1 200 OK');
$posts_to_show = 1000; // 获取文章数量
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<urlset xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance" rel="external nofollow" >http://www.w3.org/2001/XMLSchema-instance</a>" xmlns="<a href="http://www.sitemaps.org/schemas/sitemap/0.9" rel="external nofollow" rel="external nofollow" >http://www.sitemaps.org/schemas/sitemap/0.9</a>"
xsi:schemaLocation="<a href="http://www.sitemaps.org/schemas/sitemap/0.9" rel="external nofollow" rel="external nofollow" >http://www.sitemaps.org/schemas/sitemap/0.9</a> <a href="http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">'" rel="external nofollow" >http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">'</a>;
?>
<!-- generated-on=<?php echo get_lastpostdate('blog'); ?>-->
<url>
<loc>http://localhost/</loc>
<lastmod><?php echo get_lastpostdate('blog'); ?></lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<?php
header("Content-type: text/xml");
$myposts = get_posts( "numberposts=" . $posts_to_show );
foreach( $myposts as $post ) { ?>
<url>
<loc><?php the_permalink(); ?></loc>
<lastmod><?php the_time('c') ?></lastmod>
<changefreq>monthly</changefreq>
<priority>0.6</priority>
</url>
<?php } // end foreach ?>
</urlset>

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

以上就是安达网络工作室关于《wordpress非插件实现xml格式网站地图》的一些看法。更多内容请查看本栏目更多内容!

本文相关话题: wordpress 网站地图
版权声明:本文为 安达网络工作室 转载文章,如有侵权请联系我们及时删除。
相关文章
Wordpress迁徙后图片地址谬误成绩的处理办法

WordPress改换空间后 需求调整的几个中央? 1.数据库衔接配置文件 wp-config.php 2.查看.htaccess文件,并修...

WordPress分类与标签等存档页完成置顶的办法

本文实例讲述了WordPress分类与标签等存档页完成置顶的办法。分享给大家供大家参考。详细剖析如下: 在word...

wordpress罕用的函数、条件判别以及文件总结

WordPress根本模板文件 一套完好的WordPress模板应至多具备如下文件: style.css : CSS(款式表)文件 index....

WordPress增加并整合Google自定义搜寻完成步骤及代码

给博客增加一个Google自定义搜寻是非常必要的,用户搜寻时高亮显示了要害词,晋升了搜寻的精确度,应用Goog...

WordPress评论邮件告诉无插件完成思绪及代码

通常咱们喜爱应用Wordpress Thread Comment 或 Mail To Commenter这两款插件前者久未更新,已测支持WordPre...

优化WordPress中文章与评论的工夫显示

很多博客都喜爱用 评论宣布于 “XXX 分钟 之前”、文章宣布于 “XXX 分钟 之前”来显示文章评论的工夫,改善...

需求提交

客服服务

亿鸽在线客服系统