I am trying to embed a Ted talk video using the shortcode:
[ted id=myid]
But it’s not working. It shows the text instead of the video.
Is there any configuration I need to check to make it work?
I am trying to embed a Ted talk video using the shortcode:
[ted id=myid]
But it’s not working. It shows the text instead of the video.
Is there any configuration I need to check to make it work?
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:
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).
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:
[ted id=981]
way they do on WordPress.comEnjoy!