How to Convert a Shortcode into ESI blocks?
-
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');
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to Convert a Shortcode into ESI blocks?’ is closed to new replies.