Change the default video URL in a post to shortcode format

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.

Topic shortcode urls posts Wordpress

Category Web


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

enter image description here

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.