how to embed youtube video in WordPress without iframe

Embedding YouTube Videos in WordPress Without iFrame: A Step-by-Step Guide

Embedding YouTube videos into your WordPress site enhances user engagement and increases time spent on the site. Traditional methods, like using an iframe, are common, yet there’s a simpler alternative: the native WordPress embed feature, along with other effective methods.

Using WordPress Auto-Embed Feature

WordPress comes with a powerful feature known as auto-embeds. It makes embedding YouTube videos straightforward without the clutter of iframe code, improving site speed and responsiveness.

  1. Copy the YouTube URL: Navigate to the YouTube video you wish to embed. Below the video, click ‘Share’ and copy the URL provided.
  2. Paste the URL into your post: In your WordPress editor, paste the URL directly into the content area. Make sure that the URL is on its own line and not hyperlinked (clickable). WordPress automatically turns it into a video embed.
  3. Publish or Preview your post: Once the URL is pasted, WordPress fetches the video from YouTube and displays a preview. You can publish or preview the post to see the embedded video in action.

This method supports not only YouTube but also other popular video platforms.

Using Shortcodes

For more control over the display, WordPress offers a shortcode method:

  1. Get the video URL: Just like the previous method, start by getting the YouTube video URL you want to embed.
  2. Use the </code> shortcode</strong>: In your post editor, wrap the URL within the <code></code> shortcode. For example: <code>https://www.youtube.com/watch?v=example. This method also automatically adjusts the video to fit the width of your content area.
  3. Edit the shortcode parameters: You can specify width and height if desired, like so: https://www.youtube.com/watch?v=example.

Utilizing WordPress Plugins

If you require more functionality, like lazy loading videos or creating video galleries, using a WordPress plugin can be ideal.

  1. Choose and install a plugin: Plugins like WP YouTube Lyte, or Embed Plus for YouTube, are popular choices. Install and activate the plugin of your choice from the WordPress plugin repository.
  2. Configure settings: Most video plugins will have a settings page where you can configure display options, player controls, and more.
  3. Embed using a shortcode or block: These plugins usually provide a shortcode or a new block in the Gutenberg editor that you can use to embed your video.

Embedding using WordPress Blocks

With the Gutenberg editor, embedding videos is visually intuitive:

  1. Open the post editor: Start by creating a new post or edit an existing one.
  2. Add a YouTube block: Click on the ‘+’ icon to add a new block and search for ‘YouTube’. Select the YouTube block.
  3. Paste the YouTube URL: Enter the URL of the YouTube video in the block settings and it will automatically embed the video.
  4. Adjust block settings: You can adjust the alignment, video title visibility, and other options directly in the block settings.

Using WordPress Custom HTML Widget

For those who prefer a little coding:

  1. Navigate to Appearance > Widgets: Select where you want to add the video.
  2. Add a Custom HTML widget: Drag the Custom HTML widget to your chosen widget area.
  3. Embed using a direct YouTube link: Though traditionally for iframe, you can use a simple HTML5 tag linking to the video URL as well, provided the direct video link is obtained which may require additional permissions or API interaction.

Benefits of Embedding Videos without iFrame

Embedding videos without using iframes can lead to faster page load times and better responsiveness. It avoids direct calls to YouTube’s iframe player, instead utilizing WordPress’s capability to handle media effectively.

Final Thoughts

Embedding YouTube videos without an iframe in WordPress simplifies workflows, making your content attractive and engaging. Whether you choose the auto-embed feature, utilize shortcodes, employ plugins, favor Gutenberg blocks, or manually code with HTML, WordPress offers robust solutions for embedding video content seamlessly and efficiently.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *