Random video wordpress shortcode

This is an example of a wordpress shortcode that would display a random video, not very technical as the video embed is hard coded in but nice and basic

<?php
function md_random_video() {
	$videos = array(
		'Video Embed Code Goes Here',
		'Another Video Embed Code Goes Here',
		'So on',
		'So forth'
	);
	$rand_vid = array_rand( $videos );

	echo $videos[$rand_vid];
}

//Shortcode for WordPress only!
add_shortcode( 'randvid', 'md_random_video' );
?>

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here

*