欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

wordpress非插件實(shí)現(xiàn)xml格式網(wǎng)站地圖

  發(fā)布時(shí)間:2014-08-03 15:22:56   作者:佚名   我要評(píng)論
這篇文章主要介紹了wordpress非插件實(shí)現(xiàn)xml格式網(wǎng)站地圖,需要的朋友可以參考下

廢話不多說,直接上代碼

復(fù)制代碼
代碼如下:

<?php
require('./wp-blog-header.php');
header("Content-type: text/xml");
header('HTTP/1.1 200 OK');
$posts_to_show = 1000; // 獲取文章數(shù)量
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<urlset xmlns:xsi="<a rel="external nofollow" >http://www.w3.org/2001/XMLSchema-instance</a>" xmlns="<a rel="external nofollow" rel="external nofollow" >http://www.sitemaps.org/schemas/sitemap/0.9</a>"
xsi:schemaLocation="<a rel="external nofollow" rel="external nofollow" >http://www.sitemaps.org/schemas/sitemap/0.9</a> <a 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>

復(fù)制上面代碼為xmlmap.php文件并傳至網(wǎng)站根目錄
http://localhost/xmlmap.php

相關(guān)文章

最新評(píng)論