Snippets: Random Background Image on Refresh

add_action( 'wp_head', function() { ?>
	<script type="text/javascript">
		( 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 );
</script>
<?php }, 99 );

Snippet Type: PHP

All PHP snippets should be added via a child theme's functions.php file or via the Code Snippets Plugin (or alternative plugin)