Title: call function called by [embed] shortcode direct
Last modified: August 19, 2016

---

# call function called by [embed] shortcode direct

 *  [davidswain](https://wordpress.org/support/users/davidswain/)
 * (@davidswain)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/call-function-called-by-embed-shortcode-direct/)
 * Hello
 * I am trying to call the function called by the [embed] shortcode directly.
 * I am storing a video url in a custom field and therefore cannot use the shortcode‘
   as is but i cannot find where the shortcode is defined.
 * My reasoning is even though the shortcode wont work, the function (if calle in
   a template) will.
 * Can anyone help?
 * David

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/call-function-called-by-embed-shortcode-direct/#post-1434525)
 * To use a shortcode in a template
 *     ```
       <?php echo do_shortcode('[catlist id=1 numberposts=5)]'); ?>
       ```
   
 *  Thread Starter [davidswain](https://wordpress.org/support/users/davidswain/)
 * (@davidswain)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/call-function-called-by-embed-shortcode-direct/#post-1434622)
 * Doesnt work im afriad!
 * I tried it with the following code:
 * `<?php echo do_shortcode('[­embed]http://www.youtube.com/watch?v=CSA657kxJQw[/
   embed]'); ?>`
 * and it just echoed the content
 * remove the echo
 * `<?php do_shortcode('[­embed]http://www.youtube.com/watch?v=CSA657kxJQw[/embed]');?
   >`
 * rendered nothing
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/call-function-called-by-embed-shortcode-direct/#post-1434626)
 * Sorry, don’t know how to do that. Might look around in wp-includes/media.php 
   to see how it handles embed shortcode stuff.
 *  Thread Starter [davidswain](https://wordpress.org/support/users/davidswain/)
 * (@davidswain)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/call-function-called-by-embed-shortcode-direct/#post-1434643)
 * Thanks Michael
 * Had a look through media.php but i dont really understand it!
 *  Thread Starter [davidswain](https://wordpress.org/support/users/davidswain/)
 * (@davidswain)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/call-function-called-by-embed-shortcode-direct/#post-1434760)
 * Should anyione be interested the solution is:
 *     ```
       if (!empty($full)) {
   
              $var = apply_filters('the_content', "[embed]" . $full . "[/embed]");
   
       		echo $var;
   
       	}
       ```
   
 * where $full is the value of the url to be embed (eg [http://www.youtube.com/watch?v=wLh6F7G7rPA](http://www.youtube.com/watch?v=wLh6F7G7rPA))
   from a custom field
 *  [luckykind](https://wordpress.org/support/users/luckykind/)
 * (@luckykind)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/call-function-called-by-embed-shortcode-direct/#post-1434787)
 * [@davidswain](https://wordpress.org/support/users/davidswain/)
 * I used your solution, however I was running into problems with other filters 
   applied to ‘the_content’… so after much searching… I finally came upon a better
   solution to this (see below) and wanted to save others the aggravation… 🙂
 *     ```
       global $wp_embed;
       $post_embed = $wp_embed->run_shortcode('[embed]your-video-url[/embed]');
       ```
   
 * _Mod Edit: Modified the code to global `$wp\_embed` instead of creating a new
   instance of the `WP\_Embed` class which is the incorrect way to do it._
 *  [archon810](https://wordpress.org/support/users/archon810/)
 * (@archon810)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/call-function-called-by-embed-shortcode-direct/#post-1434806)
 * [@luckykind](https://wordpress.org/support/users/luckykind/), brilliant, I was
   looking to see why do_shortcode with embed wasn’t working – it was driving me
   nuts. Your solution works great, though it’s so silly that we need to do this
   so manually.

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

The topic ‘call function called by [embed] shortcode direct’ is closed to new replies.

## Tags

 * [embed](https://wordpress.org/support/topic-tag/embed/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 4 participants
 * Last reply from: [archon810](https://wordpress.org/support/users/archon810/)
 * Last activity: [15 years, 3 months ago](https://wordpress.org/support/topic/call-function-called-by-embed-shortcode-direct/#post-1434806)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
