wordpress非插件實現(xiàn)xml格式網(wǎng)站地圖
廢話不多說,直接上代碼
<?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>
復制上面代碼為xmlmap.php文件并傳至網(wǎng)站根目錄
http://localhost/xmlmap.php
上一篇:WordPress修改新用戶注冊郵件內(nèi)容的方法
欄 目:WordPress
下一篇:WordPress實現(xiàn)網(wǎng)站投稿者也可以上傳圖片的方法
本文標題:wordpress非插件實現(xiàn)xml格式網(wǎng)站地圖
本文地址:http://mengdiqiu.com.cn/a1/WordPress/12742.html
您可能感興趣的文章
- 05-31wordpress修改后臺登錄地址教程
- 05-31WordPress自定義用戶頭像實現(xiàn)代碼
- 01-11修改wordpress上傳臨時目錄解決wordpress無法安裝插件包的方法
- 01-11WordPress增加文章排序方式
- 01-11自己做wordpress評論插件修改評論樣式(兩步美化評論內(nèi)容)
- 01-11wordpress get
- 01-11wordpress獲取文章評論數(shù)過濾掉作者代碼分享
- 01-11在wordpress文章末尾添加內(nèi)容的簡單方法
- 01-11不用wordpress插件顯示文章瀏覽統(tǒng)計功能代碼修改(原理分析)
- 01-11wordpress dynamic


閱讀排行
本欄相關(guān)
- 05-31wordpress修改后臺登錄地址教程
- 05-31WordPress自定義用戶頭像實現(xiàn)代碼
- 01-11WordPress增加文章排序方式
- 01-11修改wordpress上傳臨時目錄解決wordpre
- 01-11wordpress get
- 01-11自己做wordpress評論插件修改評論樣式
- 01-11在wordpress文章末尾添加內(nèi)容的簡單方
- 01-11wordpress獲取文章評論數(shù)過濾掉作者代
- 01-11wordpress dynamic
- 01-11不用wordpress插件顯示文章瀏覽統(tǒng)計功
隨機閱讀
- 01-11ajax實現(xiàn)頁面的局部加載
- 04-02jquery與jsp,用jquery
- 08-05DEDE織夢data目錄下的sessions文件夾有什
- 08-05織夢dedecms什么時候用欄目交叉功能?
- 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
- 01-10delphi制作wav文件的方法
- 01-10C#中split用法實例總結(jié)
- 01-10使用C語言求解撲克牌的順子及n個骰子
- 08-05dedecms(織夢)副欄目數(shù)量限制代碼修改
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文