Snippet: Random Background Image on Refresh
add_action( 'wp_head', function() { ?>
( function( $ ) {
$( document ).ready(function() {
var images = ['image_url_1', 'image_url_2', 'image_url_3'];
$( 'body' ).css( {
'background-image': 'url(' + images[Math.floor(Math.random() * images.length)] + ')'
} );
} );
} ) ( jQuery );
<?php }, 99 );
All PHP snippets should be added via child theme's functions.php file or via a plugin (we recommend WPCode)