[ad_1]
I have created a PHP function for random text. Ideally, I would like to generate a random text on every page load or set it to a low TTL using ESI.
Is it possible to convert my custom shortcode into an ESI block?
function display_random_text() {
// Array of texts
$texts = [
"Text 1",
"Text 2",
"Text 3",
// Add more texts here
];
// Randomly pick a text
$random_text = $texts[array_rand($texts)];
// Return the text
return $random_text;
}
add_shortcode('random_text', 'display_random_text');