Created
April 8, 2025 18:14
-
-
Save gdnwebmedia/9fceaac8e26b1ce02f1f2c7ffea3b0da to your computer and use it in GitHub Desktop.
Load random image from array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###Load random image from array | |
//Usage | |
// {echo:get_random_image} | |
// Check if the function is already defined | |
if (!function_exists('get_random_image')) { | |
function get_random_image() { | |
$images = array( | |
'/wp-content/uploads/hero-one.webp', | |
'/wp-content/uploads/hero-two.webp' | |
); | |
return $images[array_rand($images)]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment