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疾速增加友谊链接性能的办法。分享给大家供大家参考。详细办法剖析如下: WordPres...

WordPress后盾删除不需求的侧边栏菜双方法

本文实例讲述了WordPress后盾删除不需求的侧边栏菜双方法。分享给大家供大家参考。 详细完成办法是在以后主...

wordpress后盾中的侧边栏增加菜单或子菜单的办法

复制代码代码如下: //该办法为向曾经存在的菜单中增加子菜单 function add_submenu() { add_submenu_page( ...

WordPress建站有哪些劣势

  你还没决议应用什么软件来构建你的新公司网站吗? 依然以为WordPress只是搭建博客吗? 在互联网上有大约2...

wordpress晋级后明码正确后盾无奈登陆的处理办法

本文实例讲述了wordpress晋级后明码正确后盾无奈登陆的处理办法。分享给大家供大家参考。详细剖析如下: 明...

用wordpress制造网站的步骤

在没有本人的网站的时分很想领有一个属于本人的网站,能够说是本人的一个欲望吧。然而当我真正的运转起来了...

需求提交

客服服务