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速度优化系列之 清算数据库的办法

目前本站曾经有300多篇日志和超越2000条评论,尽管数据量不是很多然而偶然会呈现,404或许是500亦或是502谬...

WordPress建站的10个重要的平安插件和技巧(图)

这篇文章重点引见10个重要的WordPress平安插件和技巧,用来维护WordPress网站或许博客。1. WP Security人工...

WordPress中让Widget 题目支持简略的HTML标签

复制代码代码如下:<?php/*Plugin Name: WPJAM HTML Widget TitleDescription: 让 Widget 题目支持简略的 HT...

详解WordPress开发中用于获取分类及子页面的函数用法

get_category get_category 可能咱们平常接触的不多,但却是很有用,网上这个函数引见的貌似不多,所以明天...

WordPress的6种主题框架比照剖析

这些规范化代码蕴含了一些根本的构造框架,你只要按本人的需求填补这个框架,可能的话需求调整某些配置。 不...

为wordpress添加网站布告性能

首先,在主题functions.php中添加上面的代码: 复制代码代码如下:function wp_dashboard_GongGao() { if...

需求提交

客服服务