TED talks shortcode not working

Unfortunately, this is going to be a problem for you.

The [ted] shortcode is specific to WordPress.com – not to a self-hosted site where you installed the software yourself from WordPress.org.

The only embeds that WordPress.org’s software supports by default are listed in the Codex:

  • YouTube (only public videos and playlists – “unlisted” and “private” videos will not embed)
  • Vimeo
  • DailyMotion
  • blip.tv
  • Flickr (both videos and images)
  • Viddler
  • Hulu
  • Qik
  • Revision3
  • Scribd
  • Photobucket
  • PollDaddy
  • WordPress.tv (only VideoPress-type videos for the time being)
  • SmugMug (WordPress 3.0+)
  • FunnyOrDie.com (WordPress 3.0+)
  • Twitter (WordPress 3.4+)

There is a plugin available for embedding Ted talks, though. TEDTalks Embedder. But it only lists compatibility through WP 3.2.1, so it may not work with the current version (it may, but I can’t guarantee it).


Alternative Actual Embeds

Here’s an alternative if you don’t want to use a plugin. Add the following to your theme’s functions.php file:

// Whitelist the TEDTalks oEmbed URL
wp_oembed_add_provider( 'http://www.ted.com/talks/*', 'http://www.ted.com/talks/oembed.json' );

function ted_shortcode( $atts ) {
    // We need to use the WP_Embed class instance
    global $wp_embed;

    // The "id" parameter is required
    if ( empty($atts['id']) )
        return '';

    // Construct the TEDTalk URL
    $url="http://www.ted.com/talks/view/lang/eng/id/" . $atts['id'];

    // Run the URL through the  handler.
    // This handler handles calling the oEmbed class
    // and more importantly will also do the caching!
    return $wp_embed->shortcode( $atts, $url );
}
add_shortcode( 'ted', 'ted_shortcode' );

Now, you can embed TEDTalks two ways:

Enjoy!

Leave a Comment