废话不多说,间接上代码
<?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博客是应用人数最多的一个开源博客顺序,动态化也是最多人像要到的成绩,关于老手来收,动态化的解...
COOKIE记载SESSION记载数据库记载缓存文件记载从技术难度上,第1、2种办法最简略,因而,下文将完成以COOKI...
WordPress引人注目的其中一个最大要素就是围绕这个内容治理零碎而进行的开发也不尽其数。因为WordPress...
要害字形容:装置 本地 如何 Wordpress 下载 应用 环境 // 版本 Windows 上一次教程将 wordpress如何装置,...
阻拦英文渣滓评论 因为绝大少数的渣滓评论都是英文的,所以国际不少冤家在应用 Some Chinese Please 插件,...