Skip to content

Instantly share code, notes, and snippets.

@robneu
Last active October 5, 2015 21:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robneu/11394049 to your computer and use it in GitHub Desktop.
Save robneu/11394049 to your computer and use it in GitHub Desktop.
WordPress video embed shortcode examples
[video src="https://www.youtube.com/watch?v=NhheiPTdZCw"]
<?php
/**
* Displays an embeded YouTube or Vimeo video if one exists.
*
* @uses Advanced Custom Fields
* @author Robert Neu
* @link http://wpbacon.com/tutorials/embed-video-wordpress-3-9/
*/
function prefix_the_video() {
// Do nothing if we have no video to embed.
if ( ! class_exists( 'acf' ) || ! get_field( 'video_embed' ) ) {
return;
}
$attr = array(
'src' => esc_url( get_field( 'video_embed' ) ),
'width' => 960,
);
echo wp_video_shortcode( $attr );
}
<?php
//Display the video.
prefix_the_video();
// Hook the video after the entry in Genesis.
add_action( 'genesis_after_entry', 'prefix_the_video' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment