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文章ID不延续的处理办法

然而固定衔接假如不必postid命名的话兴许发现不了,然而大葱不断应用的就是这种固定链接。假如你网速不佳的...

在WordPress中应用PHP脚原本判别访客来自什么国度

区分访客国度有什么用&#63; 这里是几个我利用该性能的例子. 1.区分网站性能 这个博客有翻译文章的性能, 这是...

wordpress开发之插件开发初识(wordpress插件开发根底)

首先,你要在wp-content/plugins/下建设一个文件夹,文件夹的名字最好只由字母、数字、&ldquo;-&rdquo;和下...

WordPress中文截取函数用法剖析

本文实例讲述了WordPress中文截取函数用法。分享给大家供大家参考。详细剖析如下: 很多冤家间接应用php su...

保障WordPress平安的完成办法

小洞不补大洞享乐。关于bloggers来说这是永恒的真谛,仅仅花一点工夫在马上就晋级上省下了很多之后修复一些...

在wordpress文章末尾增加内容的简略办法

1、修正文章页面模板single.php关上模版文件中的single.php,在其中搜寻在这行上面加上:复制代码代码如下:...

需求提交

客服服务