I want to add video from youtube/vimeo to my post.Whenever i add a video to my post ,there will display a link like https://www.youtube.com/watch?v=dsUXAEzaC3Q in my admin(Add new post ),and in the front end it will display the video.But the problem is, i want to show the video like a shortcode example [video url=”https://www.youtube.com/watch?v=dsUXAEzaC3Q”][/video]in the place of original video.That is show the shortcode like above instead of the video in front end.How can it possible.Please help me.
-
Not sure I understand you correctly … do you mean Show shortcode without executing it? – fuxia♦ Apr 23 '13 at 8:00
-
when click on the shortcode it should display the video. – MindZ Apr 23 '13 at 8:13
-
Youtube is already supported as part of the embed functionality along with various other popular video sites. – t31os Apr 23 '13 at 8:20
To render the shortcode output with a clickable link while it still looks like a shortcode, you have to replace the built-in shortcode:
add_shortcode( 'video', 'wpse_96840_literal_video' );
function wpse_96840_literal_video( $atts )
{
$url = $atts['url'];
return '<code>'
. sprintf( '[video url="<a href=\"%1$s\">%1$s</a>"][/video]', $url )
. '</code>';
}
Result
-
The built-in shortcode is not yet in WordPress. It will come in version 3.6. As to where to put this code: use a custom plugin. – fuxia♦ Apr 23 '13 at 10:07