WordPress do_shortcode() with [embed]

How to add oEmbed parsing for media URL manually.

This code does not work:

echo do_shortcode( '{embed}' . $media_url . '{/embed}' );

Solution:

global $wp_embed;
echo $wp_embed->run_shortcode( '{embed}' . $media_url . '{/embed}' );

1 comment on “WordPress do_shortcode() with [embed]

  1. Pingback: [WordPress] do_shortcodeでTweetを埋め込めないので、別の方法をとる | モノグサにお灸 | 明日なまけるために、今日はがんばってみる。

Leave a Reply

Your email address will not be published. Required fields are marked *