|

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

  • | | |

    Version 4.0

    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 New TehJoey is officially launched. You may have been noticing over the last few days, when layouts were switching back…

  • |

    Announcing WP in One Month

    I’m passionate about is teaching. I speak at conferences, write tutorials and books, developed and teach courses. Last week, An Event Apart hosted a Front End Development Round Table and the question, “What makes a senior developer,” came up. The general feeling was someone who can do and teach makes a senior developer. This reinforced…

  • |

    Building Web Apps with WordPress

    I just finished reading up a book that was co-written by my friend Jason Coleman called Building Web Apps with WordPress. I picked it up because while I’m generally good at developing themes, I know there were some things I was missing- types of code, optimizations, plugin best practices, etc. I wanted to improve my WordPress…

  • |

    My 2017 Learning Plan: Javascript Edition

    So…I write about learning a lot. Turns out, I really love learning. I also like coming up with plans about learning, and telling you about them. The last one that went really well was the one I did in January 2014, when I learned Sass. But now that I’m no longer at an agency, I…

  • |

    WordPress Helper Functions for Detecting IE

    The other day I was working on a problem where I wanted to check if a website was using a specific browser (in this case IE) and version (in this case 9 or below). I came up with 2 functions that would serve an a nice, reusable check for both. These can also be extended…

  • |

    Upcoming Speaking Events

    As it turns out, I’m speaking a couple of times next week on WordPress Custom Post Types- check out the information below and register if you’d like! Connecting Custom Post Types WP Summit, Online, June 11th, 2013 at 12pm CST Use the code 20JOE for 20% off. DIY Custom Post Types NEPA WP Meetup, Library…

2 Comments

Comments are closed.