Last active
October 5, 2015 21:49
-
-
Save robneu/11394049 to your computer and use it in GitHub Desktop.
WordPress video embed shortcode examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[video src="https://www.youtube.com/watch?v=NhheiPTdZCw"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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