Skip to content

Instantly share code, notes, and snippets.

View rabindratharu's full-sized avatar

Rabindra Tharu rabindratharu

  • Kathmandu (Nepal)
View GitHub Profile
@rabindratharu
rabindratharu / functions.php
Created March 21, 2025 10:27 — 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;
}