close
Blogtrottr
海芋小站
提供實用軟體教學,介紹有趣網站及資訊,豐富電腦人生 
如何調整 WordPress RSS 更新頻率,讓讀者更快知道我們發表了新文章?
Nov 2nd 2014, 17:15, by 張海芋

[embedded content]

wordpress-logo-notext-rgb

有自架 WordPress 的朋友可能會發現,當你更新完一篇文章時,網站的 RSS 並不一定會馬上有那篇文章,這是因為 WordPress RSS 快取的原因,在預設的情況下,WordPress 的 RSS 內容是 12 小時才會更新一次,當然我們可以把更新的頻率調密集一點,讓讀者們能更快知道我們已經有發表了一篇新的文章,怎麼做呢?其實很簡單喔!

首先,你必須打開【外觀】→【主題編輯器】,並且找到「functions.php」。

接著輸入以下的程式碼:

1
2
3
4
5
6
7
8
9
10
function return_7200( $seconds )
{
   return (int) 7200;
}
 
add_filter( 'wp_feed_cache_transient_lifetime' , 'return_7200' );
 
$feed = fetch_feed( $feed_url );
 
remove_filter( 'wp_feed_cache_transient_lifetime' , 'return_7200' );

其中,7200 代表的是 7200 秒更新一次,也就是說每2小時都會更新一次,但這樣也相對會讓你的伺服器的負擔更重。

資料來源:Plugin API/Filter Reference/wp feed cache transient lifetim

[embedded content]
如果你喜愛這篇文章, 請考慮 留言回應 或者 訂閱 RSS feed 以獲得更多的文章更新資訊。若有商業上的需求,也歡迎透過 合作提案 與我聯絡。本站文章非經授權請勿「全文轉貼」,引用時請註明來源,謝謝。

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 nbv2x14xp1p6k 的頭像
    nbv2x14xp1p6k

    線上遊戲排行榜2013/2014,進擊的巨人線上看,candy crush saga外掛,正妹寫真三圍

    nbv2x14xp1p6k 發表在 痞客邦 留言(0) 人氣()