How To Add Embed Video In WordPress

How To Add Embed Video In WordPress

oEmbed method is a protocol permitting embedding videos, text, images, etc., by providing the URL to embed the targeted media. There’s no need for any type of coding knowledge for this process.

First, you need to go to YouTube. Then you have to find the video for embedding as you like and then we have to copy the URL of the video.

We have use the wp_oembed_get() function.

wp_oembed_get() function use to fetch the embed HTML for the provided URL using oEmbed function.

Parameters for the oembed function:

  1. $url: The URL from we have selected video from the youtube.
  2. $args: This is an Optional argument for retrieving embed HTML.
    1. width: It’s an optional argument, We passed the width of the video.
    2. height: It’s an optional argument, We passed the height of the video.

Here are the example of wp_oembed_get() function.

wp_oembed_get( 'https://youtu.be/2yCJjsxxNQw', array( 'width' => 600 ) );

Output:

 

Submit a Comment

Your email address will not be published.

Subscribe

Select Categories