Dougal Campbell's geek ramblings

WordPress, web development, and world domination.

Quick Tip: Faster WordPress News

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

If you’d like to do the same, add this code snippet to your theme’s functions.php file, or add a plugin header to it and install as a regular plugin:

// Customize the 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 the cache lifetime for the Planet WordPress feed data to be two hours instead of twelve.

If you use this tip, I also recommend increasing the number of feed items displayed, as suggested in my 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 to have a typo in your code. Shouldn’t the add_filter line read like this (e.g. remove that extra closing parentheses):
    add_filter( 'wp_feed_cache_transient_lifetime', 'dc_reschedule_rss_fetch', 10, 2 );

    • Dougal says:

      Yes, thank you for pointing it out. I’ve corrected the code.

      I cut-and-pasted from a terminal window, and it cut the end of that line off. When I manually “fixed” it, I introduced the 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 my blog. Two hours after, the content don’t display for some of my posts. Only the 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 my blog

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

  10. Thanks for the code. I will make use of it right now.

  11. Therealnews says:

    Thanks for the info. I am switching to wordpress soon and have been searching for information so I can get it properly setup. This will help with keeping things up to date. Thanks.

  12. This is such a good discussion. I’m sure lots of readers are enjoying this.

Leave a Reply

%d bloggers like this: