Support » Fixing WordPress » 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?


Viewing 7 replies - 1 through 7 (of 7 total)
  • To use a shortcode in a template

    <?php echo do_shortcode('[catlist id=1 numberposts=5)]'); ?>

    Doesnt work im afriad!

    I tried it with the following code:

    <?php echo do_shortcode('[­embed][/embed]'); ?>

    and it just echoed the content

    remove the echo

    <?php do_shortcode('[­embed][/embed]'); ?>

    rendered nothing

    Sorry, don’t know how to do that. Might look around in wp-includes/media.php to see how it handles embed shortcode stuff.

    Thanks Michael

    Had a look through media.php but i dont really understand it!

    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 from a custom field


    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.

    @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.