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 gravatar应用本地头像进步网页关上速度

WordPress默许的头像是读取gravatar.com上的图片的,关于国际用户来说会使网页关上速度变慢。所以我决议删除...

详解WordPress中的头像缓存和代理中的缓存更新办法

wordpress评论中的头像是应用Gravatar的头像效劳(Gravatar民间注册地址:http://en.gravatar.com),用户的...

wordpress dynamic_sidebar()函数应用办法

dynamic_sidebar()函数用来支持自定义sidebar侧边栏,能够自定义Widget插件,比方为侧边栏增加最近文章,文...

WordPress主题制造之模板文件的引入办法

get_template_part() 用来援用模板文件,相似于 get_header()、get_sidebar() 和 get_footer(),只不过这个...

wordpress固定链接翻译插件 主动将题目翻译成英文

wpslugtranslate插件引见: 经过该插件,能够让wordpress中文博客的博主应用/%postname%.html方式的固定链接...

WordPress 自定义文章列表列的完成办法

上一篇,咱们应用 Meta Box 为文章增加了一个&ldquo;推荐指数&rdquo;字段。增加后用了一段工夫,仿佛不那么...

需求提交

客服服务