废话不多说,间接上代码
<?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格式网站地图》的一些看法。更多内容请查看本栏目更多内容!
update_user_option()函数 update_user_option()函数作用利用全局博客权限更新用户选项。 用户选项相似于用...
WordPress菜单CSS类选项设置办法: 1、点开WordPress菜单设置页面右上角“显示选项”,勾选外面的...
本文实例讲述了在WordPress治理页面底部自定义文字的办法,分享给大家供大家参考。详细完成办法如下: 把上面...
第一种办法:我的这个博客不断都在网上运转,明天想把它在本地架设一个,包括数据库都和网上的如出一辙。详...
本文实例讲述了WordPress完成评论后可显示内容中附件下载地址的办法。分享给大家供大家参考,详细如下: 最...
home_url()(获取首页链接) ome_url() 函数用来获取 WordPress 的首页链接。 用法 home_url( $path, $sch...