Why isn’t this youtube shortcode working?

echo do_shortcode('https://www.youtube.com/watch?v=vZBCTc9zHtI');

Is merely printing


out onto the page.

I know I can display the video with html with

<iframe src="http://www.youtube.com/embed/vZBCTc9zHtI" width="560" height="315" frameborder="0" allowfullscreen></iframe>

but I’m trying to leverage wordpress’ built-in methods. How do I do this?

4 Answers

I think this is what you are looking for:

<?php echo wp_oembed_get('https://www.youtube.com/watch?v=vZBCTc9zHtI'); ?>

For more details check this documentation.

Leave a Comment