Title: oEmbed question
Last modified: August 22, 2016

---

# oEmbed question

 *  Resolved [justinmaurerdotdev](https://wordpress.org/support/users/360zen/)
 * (@360zen)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/oembed-question/)
 * So, I’m new to CMB2 and trying to allow the client to embed videos with a url
   using the oEmbed custom field. Everything seems to be working properly, but I’m
   not sure how to echo the field properly to get it to spit out the embed code 
   instead of the url value.
 * This code:
 *     ```
       $video = get_post_meta( get_the_ID(), '_cmb2_video_embed', true );
       echo $video;
       ```
   
 * results in the text “[http://youtu.be/xxxxxxxx&#8221](http://youtu.be/xxxxxxxx&#8221);.
 * EDIT:
    This code ([from this thread](https://wordpress.org/support/topic/call-function-called-by-embed-shortcode-direct?replies=8#post-1577437)):
 *     ```
       global $wp_embed;
       echo $wp_embed->run_shortcode('[­embed]'.$video.'[/embed]');
       ```
   
 * results in the text “[embed]http://youtu.be/xxxxxxxx[/embed]“.
 * Any help is much appreciated. Thanks in advance!
    [https://wordpress.org/plugins/cmb2/](https://wordpress.org/plugins/cmb2/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [justinmaurerdotdev](https://wordpress.org/support/users/360zen/)
 * (@360zen)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/oembed-question/#post-5588164)
 * I believe I have answered my own question. It appears that the following is working
   as expected:
 *     ```
       $video = get_post_meta( get_the_ID(), '_cmb2_video_embed', true );
       echo wp_oembed_get( $video );
       ```
   
 * If there is a better way to do it, I’d love to know it. Otherwise, I’ll consider
   this resolved.
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [11 years, 5 months ago](https://wordpress.org/support/topic/oembed-question/#post-5588278)
 * You could always add the `the_content` filter to the `$video` result, but that
   may not be much different than the solution you have now, and it’d make you have
   to contend with other things that add filters to the_content.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘oEmbed question’ is closed to new replies.

 * ![](https://ps.w.org/cmb2/assets/icon.svg?rev=2866672)
 * [CMB2](https://wordpress.org/plugins/cmb2/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cmb2/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cmb2/)
 * [Active Topics](https://wordpress.org/support/plugin/cmb2/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cmb2/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cmb2/reviews/)

## Tags

 * [oEmbed](https://wordpress.org/support/topic-tag/oembed/)

 * 2 replies
 * 2 participants
 * Last reply from: [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/oembed-question/#post-5588278)
 * Status: resolved