{"id":245,"date":"2023-09-06T00:02:50","date_gmt":"2023-09-05T23:02:50","guid":{"rendered":"https:\/\/harmonweb.com\/blog\/?p=245"},"modified":"2023-09-06T00:02:50","modified_gmt":"2023-09-05T23:02:50","slug":"how-to-easily-embed-iframe-code-in-wordpress-3-methods","status":"publish","type":"post","link":"https:\/\/harmonweb.com\/blog\/how-to-easily-embed-iframe-code-in-wordpress-3-methods\/","title":{"rendered":"How to Easily Embed iFrame Code in WordPress (3 Methods)"},"content":{"rendered":"\n<p>Do you want to embed an iFrame code in a WordPress post or page?<\/p>\n\n\n\n<p>IFrames provide an easy way to embed video or other content to your site without uploading it. Many third-party platforms like YouTube allow users to use iframe to embed content from their website.<\/p>\n\n\n\n<p>In this article, we\u2019ll show you how to easily embed iFrame code in WordPress using multiple methods.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">What is iFrame?<\/h4>\n\n\n\n<p>An iFrame lets you embed videos or other content on your site. This means you can display a video on your site without actually hosting that video.<\/p>\n\n\n\n<p>The iframe is like opening a window on your site to display external content. The actual content is still loaded from the source that you are embedding from.<\/p>\n\n\n\n<p>To add an iframe, you need to add a special HTML code. Don\u2019t worry if that sounds quite technical.<\/p>\n\n\n\n<p>We\u2019re going to show you the easiest way to embed an iFrame in your WordPress blog.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Why Use iFrames?<\/h4>\n\n\n\n<p>A key reason to use iFrames is to avoid having to host videos or other resources on your site, which will use up your bandwidth and storage space.<\/p>\n\n\n\n<p>Also, iFrames let you avoid infringing on other people\u2019s copyrighted content. Instead of downloading their video or other content then uploading it to your site, you simply add it to your page using an iFrame.<\/p>\n\n\n\n<p>Another advantage is that if the original content is changed, it will automatically be updated in the iFrame too.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn3.wpbeginner.com\/wp-content\/uploads\/2020\/12\/people-website-video.png\" alt=\"An image of cartoon people adding content to a website\" class=\"wp-image-87498\" title=\"An image of cartoon people adding content to a website\"\/><\/figure>\n\n\n\n<p>There are also some drawbacks to using iFrames. Not all websites let you put their content into an iFrame. Also, the iFrame may end up too big or small for your page, and you will need to manually adjust it.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>This is why many platforms like WordPress prefers oEmbed. You can use oEmbed to embed videos as well as some other types of content by simply pasting a URL into your WordPress post. The content will automatically be resized to fit, and it will be the right size even on mobile devices.<\/p>\n\n\n\n<p><strong>Important:<\/strong> WordPress doesn\u2019t support oEmbed for Facebook and Instagram posts. For more on this, check out our full guide on the Facebook \/ Instagram oEmbed issue and how to fix it.<\/p>\n\n\n\n<p>Another great alternative to iFrames is to use a social feeds plugin. We recommend using <a href=\"https:\/\/smashballoon.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Smash Balloon<\/a>\u2018s plugins. These let you display content from Facebook, Instagram, Twitter, and YouTube.<\/p>\n\n\n\n<p>Having said that, let\u2019s take a look at three different ways to add iFrames to your site.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. Use the Source\u2019s Embed Code to Add iFrame in WordPress<\/h4>\n\n\n\n<p>Many large sites have an Embed option for their content. This gives you the special iFrame code that you need to add to your site.<\/p>\n\n\n\n<p>On YouTube, you can get this code by going to the video on YouTube, then clicking the Share button below it.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn4.wpbeginner.com\/wp-content\/uploads\/2020\/12\/share-button-youtube.png\" alt=\"Clicking the Share button for your chosen YouTube video\" class=\"wp-image-87481\" title=\"Clicking the Share button for your chosen YouTube video\"\/><\/figure>\n\n\n\n<p>Next, you will see a popup with several share options. Simply click on the Embed button.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn4.wpbeginner.com\/wp-content\/uploads\/2020\/12\/embed-code-button-youtube.png\" alt=\"Clicking the Embed button to get the YouTube embed code\" class=\"wp-image-87482\" title=\"Clicking the Embed button to get the YouTube embed code\"\/><\/figure>\n\n\n\n<p>Now, YouTube will show you the iFrame code. By default, YouTube will include the player controls. We also recommend that you enable the privacy-enhanced mode.<\/p>\n\n\n\n<p>After that, go ahead and click the Copy button to copy the code.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn3.wpbeginner.com\/wp-content\/uploads\/2020\/12\/embed-video-code-copy.png\" alt=\"Copying the embed code for the YouTube video\" class=\"wp-image-87483\" title=\"Copying the embed code for the YouTube video\"\/><\/figure>\n\n\n\n<p>Now, you can paste that code into any post or page on your site. We\u2019re going to add it to a new page in the block editor.<\/p>\n\n\n\n<p>To create a new page, go to <strong>Pages \u00bb Add New<\/strong> in your WordPress dashboard.<\/p>\n\n\n\n<p>Then, add an HTML block to your page.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn4.wpbeginner.com\/wp-content\/uploads\/2020\/12\/add-custom-html-block-wordpress.png\" alt=\"Adding a custom HTML block to WordPress\" class=\"wp-image-87499\" title=\"Adding a custom HTML block to WordPress\"\/><\/figure>\n\n\n\n<p>Now, you need to paste the YouTube iFrame code into this block.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn4.wpbeginner.com\/wp-content\/uploads\/2020\/12\/youtube-iframe-code-in-html-block.png\" alt=\"Pasting the YouTube HTML code into the iFrame block\" class=\"wp-image-87485\" title=\"Pasting the YouTube HTML code into the iFrame block\"\/><\/figure>\n\n\n\n<p>You can then preview or publish your page to see the YouTube video embedded there.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn.wpbeginner.com\/wp-content\/uploads\/2020\/12\/video-embedded-on-website.jpg\" alt=\"Viewing the embedded video live on your website\" class=\"wp-image-87486\" title=\"Viewing the embedded video live on your website\"\/><\/figure>\n\n\n\n<p><strong>Tip:<\/strong> If you\u2019re using the old classic editor, you can still add iFrame code. You need to do so in the Text view.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn4.wpbeginner.com\/wp-content\/uploads\/2020\/12\/youtube-iframe-code-in-classic-editor.png\" alt=\"Adding the YouTube iFrame code in the classic editor\" class=\"wp-image-87487\" title=\"Adding the YouTube iFrame code in the classic editor\"\/><\/figure>\n\n\n\n<p>Switching between the visual and text view on the Classic Editor can cause issues with the iFrame code.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2. Using the iFrame WordPress Plugin to Embed an iFrame<\/h4>\n\n\n\n<p>This method is useful as it allows you to create an iframe to embed content from any source, even if that source doesn\u2019t provide an embed code.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>Upon activation, the plugin will start working straight away with no setup needed. Go ahead and edit or create a post or page. Then, add a shortcode block.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn4.wpbeginner.com\/wp-content\/uploads\/2020\/12\/add-shortcode-block-wordpress.png\" alt=\"Adding a shortcode block in the block editor\" class=\"wp-image-87488\" title=\"Adding a shortcode block in the block editor\"\/><\/figure>\n\n\n\n<p>After that, you can use this shortcode to enter your iFrame code.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<\/td><td><code>[iframe src=\"URL goes here\"]<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Simply replace <em>URL goes here<\/em> with the URL of the content you want to embed on your site. We are embedding a Google map.<\/p>\n\n\n\n<p><strong>Tip:<\/strong> You may need to use the Embed option to get the direct URL of the content. You need to use just the URL, not the rest of the embed code.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn2.wpbeginner.com\/wp-content\/uploads\/2020\/12\/google-maps-iframe-shortcode.png\" alt=\"The shortcode to embed a Google map\" class=\"wp-image-87489\" title=\"The shortcode to embed a Google map\"\/><\/figure>\n\n\n\n<p>Next, preview or publish your post. You should see the Google map embedded on your site.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn3.wpbeginner.com\/wp-content\/uploads\/2020\/12\/google-map-embedded-on-website.jpg\" alt=\"The Google map embedded on the website\" class=\"wp-image-87490\" title=\"The Google map embedded on the website\"\/><\/figure>\n\n\n\n<p>You can optionally add parameters to the iFrame shortcode to change how the embedded content displays. For instance, you could set the width and height, and add or remove a scrollbar or border. You can find details on the iFrame plugin\u2019s page.<\/p>\n\n\n\n<p><strong>Tip:<\/strong> If you\u2019re using the Classic editor, you can simply paste the shortcode into your post or page. You don\u2019t need to switch to the Text view.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn3.wpbeginner.com\/wp-content\/uploads\/2020\/12\/shortcode-in-classic-editor.png\" alt=\"Adding the shortcode in the classic editor\" class=\"wp-image-87500\" title=\"Adding the shortcode in the classic editor\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">3. Manually Creating the iFrame Code and Embedding in WordPress<\/h4>\n\n\n\n<p>If you prefer not to use an iFrame plugin, then you can create the iFrame code manually. To do this, you need to add an HTML block in the WordPress content editor.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn3.wpbeginner.com\/wp-content\/uploads\/2020\/12\/manual-method-adding-custom-html-block.png\" alt=\"Adding a custom HTML block\" class=\"wp-image-87502\" title=\"Adding a custom HTML block\"\/><\/figure>\n\n\n\n<p>First, you need to paste this code into your HTML block.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<\/td><td><code>&lt;iframe src=\"URL goes here\"&gt;&lt;\/iframe&gt;<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Simply replace \u201cURL goes here\u201d with the direct URL for the content that you want to embed. You only need the URL itself.<\/p>\n\n\n\n<p>Here, we\u2019re embedding a map from Google.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn2.wpbeginner.com\/wp-content\/uploads\/2020\/12\/iframe-html-google-map-url.png\" alt=\"Entering the iFrame code for the Google map\" class=\"wp-image-87501\" title=\"Entering the iFrame code for the Google map\"\/><\/figure>\n\n\n\n<p>You can add extra parameters to the HTML tag. For instance, you could set the width and height of your iFrame. The code below means your embedded content will display 600 pixels wide and 300 pixels high.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<\/td><td><code>&lt;iframe src=\"URL goes here\" width=\"600\" height=\"300\"&gt;&lt;\/iframe&gt;<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>This is useful if you need to restrict the embedded content to a smaller space.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn2.wpbeginner.com\/wp-content\/uploads\/2020\/12\/set-width-height-iframe.jpg\" alt=\"The Google map on the site with a set height and width\" class=\"wp-image-87492\" title=\"The Google map on the site with a set height and width\"\/><\/figure>\n\n\n\n<p><strong>CREDIT: WPBeginner<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Do you want to embed an iFrame code in a WordPress post or page? IFrames provide an easy&hellip;<\/p>\n","protected":false},"author":1,"featured_media":248,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[158],"tags":[],"class_list":["post-245","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-troubleshooting"],"_links":{"self":[{"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/posts\/245","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/comments?post=245"}],"version-history":[{"count":2,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/posts\/245\/revisions"}],"predecessor-version":[{"id":319,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/posts\/245\/revisions\/319"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/media\/248"}],"wp:attachment":[{"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/media?parent=245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/categories?post=245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/harmonweb.com\/blog\/wp-json\/wp\/v2\/tags?post=245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}