wordpress snippets last updated   : January 29, 2015
we now have 646 snippets

Shortcode for HTML5 video in posts

wordpress snippet

Adding the first snippet to the functions.php of your wordpress theme will create a new HTML5 video shortcode. Place the shortcode below in your posts to display your video.

snippet :  PHPcopy
function html5_video($atts, $content = null) {
		"src" => '',
		"width" => '',
		"height" => ''
	), $atts));
	return '<video src="'.$src.'" width="'.$width.'" height="'.$height.'" controls autobuffer>';
add_shortcode('video5', 'html5_video');
source →
snippet :  SHORTCODEcopy
[video5 src="http://your-site/videos/your-video.mp4" width="720" height="480"]
source →

Did you like this post? If so please share it with your friends. Thanks!

  • Anonymous

    this is a very nice snippet sir.

    • http://wpsnipp.com Kevin Chard

      Thanks glad that you like it.

  • http://www.cliffpaulick.com Cliff Paulick

    Below, not Bellow. Delete this comment once fixed. Thanks for another great snippet.

    • http://wpsnipp.com Kevin Chard

      Cheers Cliff, fixed the typo. Glad you like the snippet.

  • http://www.cliffpaulick.com Cliff Paulick

    How can there be multiple video files – same exact video but different sizes/resolutions for different screen sizes?

    • http://wpsnipp.com Kevin Chard

      ¬†with this sample you really can’t do something like that, if you want to do something more advanced with wordpress and video I would look into http://jplayer.org/