Do you want to embed iFrame code in a WordPress post or page?
iFrames are an easy way to show video or other content on your site without uploading it. Many third-party platforms like YouTube provide iFrame code that you can simply paste into your website.
In this article, we will show you how to easily embed iFrame code in WordPress.
Why Should I Embed iFrame Code in WordPress?
An iFrame lets you embed videos or other content on your site without actually having to host that video. This can save you bandwidth and storage space, which is why you should never upload a video directly to WordPress.
In addition to improving your WordPress speed and performance, the iFrame will update automatically if the original content changes. This means visitors will always see the latest version of the content.
Embedding copyrighted content via an iFrame also doesn’t violate copyright, so it can help protect you against lawsuits.
Having said that, let’s see how you can easily embed iFrame code in WordPress. Simply use the quick links to jump straight to the method you want to use:
Method 1: Use the Source’s Embed Code to Add iFrame in WordPress (Quick and Easy)
Many large video hosting sites have an ‘Embed’ option that gives you access to the iFrame code you need to add to your site.
If the website has any ‘Sharing’ or ‘Embed’ settings, then this is often the quickest and easiest way to embed content.
The exact steps will vary depending on the platform, but let’s look at YouTube as an example. To embed YouTube videos in WordPress, simply click on the ‘Share’ button below the video you want to use.
After that, you’ll see a popup with different sharing options.
Simply go ahead and click on the ‘Embed’ button.
YouTube will now show you the iFrame code.
By default, YouTube will check the ‘Show player controls’ box, but we also recommend enabling privacy-enhanced mode. This mode allows visitors to watch the embedded content on your WordPress website without it influencing their browsing experience on YouTube.
After that, go ahead and click the ‘Copy’ button.
Simply open the page and then click on the ‘+’ button. In the popup that appears, start typing ‘HTML’ to find the custom HTML block.
When the right block appears, click to add it to your page.
Then, simply paste the YouTube iFrame code into the block.
You can now publish your page to see the YouTube video live on your WordPress blog.
Method 2: Using a WordPress Plugin (Works With All Websites)
Not every third-party website provides a ready-made embed code. If you can’t find any ‘Share’ or ‘Embed’ settings, then you can easily create your own iFrame code using the iFrame plugin.
First, you need to install and activate the iFrame plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.
Upon activation, the plugin will start working straight away with no setup needed. Simply go to the page or post where you want to embed content and add a Shortcode block.
After that, add the following shortcode:
[iframe src="URL goes here"]
Simply replace ‘URL goes here’ with the URL of the content you want to embed on your site.
Tip: Depending on the source, you may need to click on a ‘Share’ or similar setting to see the content’s direct, embeddable URL.
After that, just preview or publish the post.
You should now see the content embedded on your website.
To see all the available parameters, you can take a look at the iFrame plugin page.
Method 3: Manually Creating the iFrame Code and Embedding in WordPress (No Plugin Required)
If you don’t want to use a special WordPress plugin, then you can create the iFrame code manually. To do this, you need to open the page or post and then add an HTML block in the WordPress content editor.
First, paste the following code into your HTML block:
<iframe src="URL goes here"></iframe>
Simply replace ‘URL goes here’ with the direct URL for the content that you want to embed.
Here, we are embedding a Google Map:
You can add extra parameters to change how the content looks on your website. For example, we are setting the width to 600 pixels and the height to 200 pixels:
<iframe src="URL goes here" width="600" height="300"></iframe>
This is useful if you need to show the embedded content in a smaller space. For example, you may want to resize the content after testing the mobile version of your WordPress website.
What Are Some iFrame Alternatives?
There are some drawbacks to using iFrames.
Not all websites let you put their content into an iFrame, and you may need to manually adjust the content so that it looks good in the available space.
Another issue is that HTTPS sites can only use iFrames for content from other HTTPS sites. Similarly, HTTP sites can only use iFrames for content from other HTTP sites.
This is why many platforms like WordPress prefer oEmbed.
Often, you can use oEmbed to embed videos and other content by simply pasting a URL into the WordPress post. WordPress will automatically resize the oEmbed to fit the available space, so it will always look perfect on desktop, smartphones, and tablets.
Important: WordPress no longer supports oEmbed for Facebook and Instagram posts by default. For more on this topic, check out our full guide on how to fix the Facebook and oEmbed issue in WordPress.
If you want to show social feeds on your website, then we recommend using a social media plugin rather than iFrames.
We hope this article helped you learn how to easily embed iFrame code in WordPress. You may also want to check out our guide on how to create a custom Instagram photo feed in WordPress or see our expert picks for the best YouTube gallery plugins for WordPress.