|

QT: Increase the WordPress RSS Widget Refresh Rate

Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don't hold it against me. One of the perils of having a 20+ year old website!

While working on the redesign to this blog, I wanted to add the “Interesting Stuff” column you see just to the right. Using the RSS feed widget built into WordPress would be perfect, except for the fact that it only updates ever 12 hours. In today’s Quick Tip, we fix that problem.

The solution is a simple one. Just add this line of code to your theme’s function file:

add_filter( 'wp_feed_cache_transient_lifetime', 
             create_function('$a', 'return 600;') );

Aha! But What does it all mean? Well let’s take it step by step.

add_filter is a WordPress function call that allows you to ‘hook’ into the WordPress core and execute a function during a certain operation. The two arguments are the hook- that is, when you want to execute a certain bit of code- and the function to execute.

In this case, our hook is wp_feed_cache_transient_lifetime. Simply put, it’s the hook that handles feed refreshes.

Finally, we have create_function('$a', 'return 600;'). This line creates a function on the fly that returns a new refresh time in seconds. I went with every 10 minutes, but use your discretion.

That’s it! Now you have a single line that allows you to control how often your feed widget refreshes.

Similar Posts

  • | | |

    Winn Cards and Comics

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website! The Winn Site is a project I have been working on for a couple of months now. The guys wanted…

  • WordCamp US, or Why I Love the WordPress Community

    Last week I attended the inaugural WordCamp US, where I spoke as well as attended the Community Summit. The Community Summit “is a smaller, work-focused event. Community leaders gather to discuss and work on issues that the WordPress community faces.” It was a great time, and between that, the actual WordCamp, and Contributor Day, I…

  • |

    Videos from May 2019

    It’s been a crazy month, and I barely blogged, but that doesn’t mean I wasn’t pumping out content. Here’s a roundup of all the video (and other content I put out in May 2019.

  • |

    Testing your Responsive Site

    Over the last year or so I’ve been involved with a few major projects that required responsive design/development. One of the most important things to remember about a responsive design is that it’s not just good enough to make sure your design shrinks with a smaller browser on your computer. Presumably, you’re doing this because…

  • |

    Fleshing Out My Work Week

    I have a confession: I’m in a bit of a funk. April was not a very productive for me. We were in Disney World for 8 days, and the rest of it, I was either sick or recovering from being sick. Trying to balance the different types of work I do and properly boxing time…

  • |

    Win All 3 of my Books in this eBook Give Away!

    With the weather getting nicer here in the Northeast (finally), me moving to @wpengine (finally), and some extra codes sitting around for electronic copies of my books, I decided I it would be nice to ring in Spring with a give away! Read on to see how you can win a eBook version of all…

2 Comments

Comments are closed.