How about a break in the blog action for some old school WordPress Tech mumbo jumbo?

I did not hear any complaints.

RSS is always on the plate here, so there’s a connection. Long ago in a web not so far away, I built this thing called Feed2JS (web site no more, but an aging repo still there) so on a web site like this, I could copy some Javascript, paste it in a post or a sidebar, and have a dynamic feed of content.

But with the Block editing system there is a built on one that makes it easy to display content from an RSS feed, no Javascript needed. WordPress has it built in as a block you can use in content or a widget (see if your fancy pants news letter site does that!)

I use it on my Cool Tech page to render the latest sites I have bookmarked in Pinboard tagged cooltech.

Over at the Open Education Global site for Open Education Week I am doing another RSS card trick. A group of educators in Europe are running all month long a blog / article series on Sharing is a Challenge. It’s quite elaborate, 16 topics were put out for selection by an invited group (I got my hand in the mix) to claim them to be writers for. Articles are written in maybe 7 languages, across three blogs, and translated at least into English, French, and Spanish.

A lot of RSS feeds in the mix. I came up with a system to subscribe to all the main feeds (per language) in our Inoreader account. There ins a folder, they can be referenced by a single feed that represents all the content. With that in operation, I just used the WordPress RSS block to embed the feed into the page.

A mini aggregation hub for the Sharing is a Challenge articles https://oeweek.oeglobal.org/16-challenges/

It’s all working fine, but I noticed that it was lagging behind articles I knew were published. I found sifting through a lot of stackExchange exchanges where people suggest cache flushing, the answer is tucked away in the fetch_feed() function (noting that WordPress uses the venerable SimplePie parser) by caching content for 12 hours. And that this can be changed via a hook into wp_feed_cache_transient_lifetime.

Because the Open Education Week site has a child theme that I often dip into, I was able to add this snippet to functions.php to make the refresh time hourly

// change RSS refresh cycle to hourly
add_filter('wp_feed_cache_transient_lifetime', 'oeweek_rss_interval');
function oeweek_rss_interval( $seconds ) {
    return 3600;
}

I guess for those without the chops or access to edit their themes, it could be wrapped in a plugin, and one could get fancy with an options box to select an interval, but I am not going down that road as this works for me.

Mostly it helps to know from now on that the WordPress RSS block is not making requests more than twice a day, likely a good call so its not hammering sources. But the beauty of WordPress and what all the folks running to other platforms or vibe coding their own, how crazy simple it is to tap into the WordPress system to make these changes.

More to come on my ever going love of the platform folks like to beat up on these days, WordPress I always adore you (the software not the company).


Featured Image: Is There Any Other Speed? flickr photo by cogdogblog shared under a Creative Commons (BY 2.0) license

A speed throttle in a boat helm, chrome bar with arrows for fast and slow.
If this kind of stuff has value, please support me by tossing a one time PayPal kibble or monthly on Patreon
Become a patron at Patreon!
Profile Picture for CogDog The Blog
An early 90s builder of web stuff and blogging Alan Levine barks at CogDogBlog.com on web storytelling (#ds106 #4life), photography, bending WordPress, and serendipity in the infinite internet river. He thinks it's weird to write about himself in the third person. And he is 100% into the Fediverse (or tells himself so) Tooting as @cogdog@cosocial.ca

Leave a Reply

Your email address will not be published. Required fields are marked *