Dougal Campbell's geek ramblings

WordPress, web development, and world domination.

Quick Tip: Faster WordPress News

By default, th' “Other WordPress News” widget in yer WordPress Dashboard only updates twice a day (every twelve hours). Personally, I like t' get updates quicker than that. I check me Dashboard several times a day t' see if there’s some new post that I should know about. So I set mine up t' update every two hours. Frequently enough t' keep me more up-t'-date, but not so frequently that it might be annoyin' t' th' Planet WordPress server.

If ye’d like t' do th' same, add this code snippet t' yer theme’s functions.php file, or add a plugin header t' it and install as a regular plugin:

// Customize th' Planet WordPress news feed update time:
  1. add_filter( 'wp_feed_cache_transient_lifetime', 'dc_reschedule_rss_fetch', 10, 2 );
  2.  
  3. function dc_reschedule_rss_fetch( $lifetime, $url ) {
  4.   if ( false !== strpos( $url, 'planet.wordpress.org' ) ) {
  5.     $lifetime = 7200; // expire after 2 hours (7200 seconds)
  6.   }
  7.   return $lifetime;
  8. }

This will set th' cache lifetime fer th' Planet WordPress feed data t' be two hours instead o' twelve.

If ye use this tip, I also recommend increasin' th' number o' feed items displayed, as suggested in me Customize Your WordPress Dashboard article!

About Dougal Campbell

Dougal is a web developer, and a "Developer Emeritus" for the WordPress platform. When he's not coding PHP, Perl, CSS, JavaScript, or whatnot, he spends time with his wife, three children, a dog, and a cat in their Atlanta area home.
This entry was posted in WordPress and tagged , , , , , , , , , , . Bookmark the permalink.

21 Responses to Quick Tip: Faster WordPress News

  1. Mark says:

    You appear t' have a typo in yer code. Shouldn’t th' add_filter line read like this (e.g, avast. remove that extra closin' parentheses):
    add_filter( 'wp_feed_cache_transient_lifetime', 'dc_reschedule_rss_fetch', 10, 2 );

    • Dougal says:

      Aye, thank ye fer pointin' it out. I’ve corrected th' code.

      I cut-and-pasted from a terminal window, and it cut th' end o' that line off. When I manually “fixed” it, I introduced th' extra close-paren by accident.

  2. Pingback: Tweets that mention Quick Tip: Faster WordPress News -- Topsy.com

  3. Pingback: Tweets that mention Quick Tip: Faster WordPress News -- Topsy.com

  4. Pingback: WordPress?????

  5. Pingback: Weekend Roundup #84

  6. Lashon says:

    Hello,
    These lines made a big bug on me blog. Two hours after, th' content don’t display fer some o' me posts. Only th' content are not visible anymore.

  7. Barbara says:

    Sehr guter Artikel. √úbrigens ist Dein Blog immer einen Besuch wert. Ich komme gern wieder hier vorbei.

  8. Bianchi Holsters says:

    Hello,
    These lines made a big bug on me blog

  9. Wow every two hours? Once a day would be enough fer me :-)

  10. Thanks fer th' code. I will make use o' it right now.

  11. Therealnews says:

    Thanks fer th' info. I am switchin' t' wordpress soon and have been searchin' fer information so I can get it properly setup, ye scurvey dog. This will help with keepin' thin's up t' date. Thanks.

  12. This is such a good discussion. I’m sure lots o' readers are enjoyin' this.

Leave a Reply

%d bloggers like this: