免外掛實現WordPress的Sitemap功能
阿新 • • 發佈:2018-12-23
生成 Sitemap 的外掛有很多,比較知名的有柳城的 Baidu Sitemap Generator 和 Google XML Sitemaps,感覺就為了生成個 Sitmap 多用外掛有點點浪費,那就用程式碼實現吧~缺點在於此為動態頁面,提交網站地圖時不知道會不會有困難。
新建一個 sitemap.php 至主題目錄下,複製如下內容:
PHP123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 | <?php/**@package WordPressTemplate Name: 站點地圖*/?><!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" |
在 WP 後臺新建一個頁面,型別為:站點地圖,不用填寫任何內容,點擊發布即可。