in Snippets, Tutorials, WordPress

Use WordPress [embed] in do_shortcode

If you’re finding this, you’ve probably had an issue trying to do this:

I haven’t looked into why it doesn’t work, but I did find that the following works:

Leave a Reply for Valeriu Tihai Cancel Reply

Write a Comment

Comment

11 Comments

  1. This was a life saver! I tried going down the WP core rabbit hole to track down why this wasn’t working and ended up stopping myself before I got in too deep. Nothing in the WP documentation mentioned any restrictions for this shortcode when using it in a template so I was pretty stumped. Then I found this – super grateful. Thanks!

  2. Great, man! You saved me, after quite a lot efforts to fix some stupid plugin, who’s support went silent on me. I start manually adding videos to this site’s page, but needed this for mobile version.

    Works great! May I buy you a coffee/beer?

    • Thanks Vladimir! My pleasure. No need for that, just have a great day and feel free to check out my new product metorik.com if you ever need anything like it 🙂

  3. Nice!

    Turns out the [embed] shortcode is actually registered to do nothing by default. It’s only used in a the_content filter… So rather than passing our shortcode through all content filters, this approach with $wp_embed->run_shortcode() is just perfect 🙂