Skip to content

Instantly share code, notes, and snippets.

View esradev's full-sized avatar
🏠
Working from home

wpstorm esradev

🏠
Working from home
View GitHub Profile
@esradev
esradev / functions.php
Created February 19, 2025 08:53 — forked from LearnWebCode/functions.php
WordPress functions to fetch external JSON (and store in transient + option backup) and also functions to setup programmatic URL patterns and use custom template files for said URLs
function get_cached_external_json($url) {
$transient_key = 'our_fetched_json_' . md5($url);
$option_key = 'our_fetched_json_backup_' . md5($url);
$cached_data = get_transient($transient_key);
if (false !== $cached_data) {
return $cached_data;
}