Skip to content

Instantly share code, notes, and snippets.

@braginteractive
Last active April 11, 2017 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save braginteractive/cde2f93bdec96f0b56b8597107b9223a to your computer and use it in GitHub Desktop.
Save braginteractive/cde2f93bdec96f0b56b8597107b9223a to your computer and use it in GitHub Desktop.
Embed responsive YouTube video into WordPress
<div class="entry-video">
<?php
$url = get_post_meta( get_the_ID(), 'helpwp_url', true);
$yt_id = helpwp_youtube_id($url);
if ($url != '') : ?>
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="//www.youtube.com/embed/<?php echo esc_html( $yt_id ); ?>" allowfullscreen></iframe>
</div>
<?php else :
the_post_thumbnail();
endif; ?>
</div><!-- .entry-video -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment