|

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

  • I recommend SiteGround Hosting, but Who is it for?

    Choosing the right hosting company can be an insurmountable task full of features, recommendations, and affiliate links*. There are a wide range of them, depending on what you need and what you know. A few months ago, for example, I switched this site to Liquid Web. Why don’t I just recommend them to everyone? Well…

  • | |

    Deleting 3 Million Spam Comments from a WordPress Database

    Over at the Crowd Favorite blog, I wrote up a post about an interesting problem I solved recently. I laid out everything you need to know there, but it involves downloading a HUGE database and putting WP-CLI to good use. If you haven’t used it before and you do development with WordPress, it’s super valuable….

  • |

    WordCamp Scranton Followup

    It’s been a little over a week since WordCamp Scranton, the dust as settled, and I have slept. First, I want to thank everyone who came out: attendees, speakers, sponsors, and volunteers. I also want to thank Johnson College for being such a great host. Finally, big thanks to Matt Mullenweg for taking time out…

  • |

    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…

  • |

    How to Improve Audio Recordings at Home

    Recording audio at home can be tough, especially if you don’t have the environment. On top of that, what app do you use to record, and how can you prevent that “robot voice” that happens if you’re recording online with other people. Let’s take a look at a few helpful techniques.

  • |

    Do We Need ANOTHER WordPress Hosting Company?

    WordPress hosting companies are a dime a dozen these days, and if you’re going to be one, you need to differentiate yourself. This could be by offering managed WooCommerce hosting, adding on a theme shop for all customers, or creating a fantastic local development environment that integrates perfectly. When it comes to WordPress host WPX, there are 3 features that differentiate them from competitors.

2 Comments

Comments are closed.