Перейти к содержимому

Как вставить iframe в wordpress

  • автор:

Как вставить iFrame на WordPress-сайт

Не секрет, что статическая веб-страница с меньшим количеством контента загружается намного быстрее, чем динамическая страница с изображениями и видео. Но эту проблему можно решить с помощью iFrame.

Что такое iFrame?

Что такое iFrame?

iFrame – элемент HTML для отображения контента с другого сайта на своем собственном. Он выглядит как дополнительное окно, через которое пользователь может взаимодействовать с контентом, размещенном на другом сайте.

Получается, что можно создать динамическую страницу, не размещая контент на своем сервере. Таким образом, можно сэкономить место на сервере и повысить скорость загрузки сайта.

Например, если транслировать видео с YouTube на своем сайте, то пользователи смогут просматривать его без дополнительной нагрузки на сервер.

Примеры использования iFrame

Рассмотрим несколько примеров iFrame, которые используются для отображения информации.

Примеры использования iFrame

Примеры использования iFrame - 2

Преимущества и недостатки iFrame

В использовании iFrame на WordPress-сайте есть и преимущества, и недостатки.

Преимущества

  • Позволяет вставлять визуальный контент.
  • Может отображать несколько рекламных объявлений.
  • Удобный способ отображения контента из внешнего источника в любом месте сайта.
  • Безопасно, поскольку у пользователей нет доступа к исходному коду контента.

Недостатки

  • iFrame могут замедлять веб-страницу.
  • Могут быть источником опасности, если ведут на вредоносные сайты.
  • Не все типы устройств поддерживают iFrame.
  • Ухудшают показатели SEO сайта.

Как вставить iFrame на WordPress-сайт, используя плагин

Существует довольно много подобных плагинов. Мы рассмотрим один из них – Advanced iFrame .

Чтобы установить плагин, просто войдите в панель администрирования WordPress и перейдите в раздел «Плагины» → «Добавить новый» и найдите плагин Advanced iFrame.

Как вставить iFrame на WordPress-сайт, используя плагин

После установки и активации плагина перейдите в раздел меню «Advanced iFrame», вкладка «Basic Settings» .

Как вставить iFrame на WordPress-сайт, используя плагин - 2

Здесь можно установить ширину, высоту, границы и вид прокрутки iFrame.

Чтобы сохранить необходимые настройки и создать шорткод, нажмите кнопку «Generate a shortcode for the current settings» .

Скопируйте код и вставьте его на страницу сайта, на которой необходимо разместить iFrame.

Ширина и высота iFrame определены внутри шорткода. При необходимости их можно менять вручную.

Вот пример размещения фрейма с помощью шорткода на одной из страниц сайта.

Чтобы изменить ширину или высоту фрейма, поменяйте значения размеров в шорткоде.

Проведем быстрый тест скорости работы WordPress-сайта до и после использования плагина для встраивания iFrame.

Разница в производительности огромна. После использования плагина количество запросов увеличилось с 8 до 98, а показатели производительности снизились с 96 до 86.

Как вручную вставить iFrame на WordPress-сайт

Синтаксис тега iFrame:

Чтобы установить необходимую ширину и высоту фрейма, добавьте в HTML-код соответствующие атрибуты и значения:

Проведем еще один тест скорости работы сайта, чтобы проанализировать производительность сайта до и после встраивания iFrame без помощи плагина.

Как вручную вставить iFrame на WordPress-сайт

Как вручную вставить iFrame на WordPress-сайт - 2

Встраивание iFrame без помощи плагина демонстрирует практически аналогичные показатели скорости.

Оба метода дают полное представление о том, насколько iFrame могут снизить скорость работы веб-страницы. Но при этом фреймы помогают сэкономить ресурсы сервера и не влияют на производительность сайта в целом

Заключение

В этой статье я рассказал, зачем использовать фреймы на WordPress-сайте, и объяснил их преимущества и недостатки. Также мы рассмотрели два способа добавления iFrame и его влияние на скорость работы сайта.

How to embed iFrame in WordPress ?

An Iframe is a method of embedding a web page into the content of another page. This is accomplished through the use of HTML elements, the URL of the external website, and parameters for how the window should look on your website.

How to use iframes in WordPress: There are several ways to construct an Iframe, just as there are numerous instances in which you would wish to utilize one. We will go through one of the most frequent ways to add Iframe to your WordPress site.

Manually adding iFrames to WordPress Page:

Adding an Iframe to a page requires only one line of code. The opening and closing HTML elements, as well as the URL of the webpage, are required.

Syntax:

Steps to embed in WordPress Page:

Step 1: Go to the page where you want the iframe to appear.

Step 2: Click on add(+) block button and select HTML from the popup.

Step 3: Insert the Iframe tag in the editor for the page you want to embed.

Note: There are a handful of limits to the source URL to be aware of. To begin, Iframes may only show content from sites that utilize the same Hypertext Transfer Protocol (HTTP) as yours. To put it another way, if your site is HTTPS, you can only embed information from other HTTPS sites. Similarly, if you use HTTP, you may only include URLs that utilize HTTP as well.

Step 4: To save your progress and publish the page, click the “Publish” button.

Step 5. Your page should now look something like the following screen.

More about the Iframe tag:

If you are able to employ this strategy, keep in mind that you may also change your Iframes to fit your website’s demands. The Iframe parameters come into play. The following are a few of the most common ones.

  • Allow: With this parameter, you may specify whether your Iframe should have certain default behaviours or features.
  • Height: The height parameter sets the pixel size of the Iframe window on your web page.
  • Width: This option allows you to choose the Iframe’s width in pixels.

For instance, the Iframe with a window size of 1080 pixels by 720 pixels, full-screen viewing enabled, and set to download after the rest of the webpage is as follows.

Summary: It’s critical to keep your website running smoothly while still staying on the right side of the law. Not only do Iframes allow you to share other people’s material ethically, but they will also allow you to show video and audio files without having to store them on your own website.

How to Easily Embed iFrame Code in WordPress (3 Methods)

Last updated on July 11th, 2023 by Editorial Staff | Reader Disclosure Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

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.

Easily embedding 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.

Adding a YouTube video to your WordPress website

Now, you can paste that code into any post or page on your site. In this guide, we’ll add it to a new page in the WordPress block editor.

Simply open the page and then click on the ‘+’ button. In the popup that appears, start typing ‘HTML’ to find the custom HTML block.

Adding a custom HTML block in WordPress

When the right block appears, click to add it to your page.

Then, simply paste the YouTube iFrame code into the block.

Pasting the YouTube HTML code into the iFrame 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.

Adding a shortcode block in the block editor

After that, add the following shortcode:

Simply replace ‘URL goes here’ with the URL of the content you want to embed on your site.

As an example, let’s add a Google Map in WordPress, as this is an easy way for stores, restaurants, and other venues to add directions on their contact form.

Tip: Depending on the source, you may need to click on a ‘Share’ or similar setting to see the content’s direct, embeddable URL.

The shortcode to embed a Google map

After that, just preview or publish the post.

You should now see the content embedded on your website.

An embedded Google Map, on a WordPress 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.

Easily embedding iframe code in WordPress

First, paste the following code into your HTML block:

Simply replace ‘URL goes here’ with the direct URL for the content that you want to embed.

Here, we are embedding a Google Map:

Entering the iFrame code for the 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:

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.

The Google map on the site with a set height and width

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.

For example, Smash Balloon makes it easy to embed content from Facebook, Instagram, Twitter, and YouTube.

An example of an Instagram feed, created using Smash Balloon

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.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

How to embed a WordPress iFrame with and without a plugin

How to embed a WordPress iFrame with and without a plugin

Sharing or featuring other creators’ content on your side can have legal difficulties.

This is where embedding an iframe code comes to offer a simple solution.

If you have a WordPress website that is focused on media, then it is essential that the content you want to provide to your audience is relevant and is going to reach them.

Here we need to be aware of our hosting space and not consume it entirely.

This article created by our team at wpDataTables, the #1 plugin for tables and charts, helps you to understand how you can use a WordPress iFrame, what it is, and how can you embed it on your site.

What is a WordPress iFrame?

By using a WordPress iFrame, you can embed a web page in the content of another one. This is done by using classic HTML tags that contain the external page link. Other specifications like how the Window appears can also be added in the custom HTML block.

This means that you can have a dynamic page on your site without hosting the content on the server. This saves a lot of space and makes your website move faster for your users.

At the same time, if you embed and not download, let’s say a video, the videos can appear on your site.

Users can watch the videos without any extra load on your serves. This is smart because the videos that are being streamed come directly from the source’s server.

You can use iFrames on almost any website or web page, and we are already starting to understand why. By using iFrames, many site owners create a medium that helps display the content or web pages from other sources. You can do all of this without being worried that you need any copyright permissions.

If you use iFrames, you can also show the content on your site without the need to host it in the WordPress Media Library.

Why is this important?

The answer is quite simple, all media files have taken up a significant amount of the storage space, and you could even slow your site down.

Why use a WordPress iFrame?

iFrame helps the website save storage and be faster. There are many users on the web to embed iFrame in WordPress without a plugin. This includes videos, images, other sites, and more. You can even use iFrame to save storage space by embedding content from other serves.

For sure, there are quite a few methods to embed content like using AJAX or HTML5 web elements or others. However, in many cases, iFrame is a better choice. For one, iFrame embedding is being used to cross-domain content. By doing so, a website user can ask the selected resources from a separate website and view it without manipulating the element.

Here are some advantages of using WordPress iFrame:

  • It lets you embed visual content for free
  • You can display multiple ads
  • It is a simple way to view content from external sources without any problems
  • It is secure, and you do not need to access the original content code

Embed iframes in WordPress with a plugin

WordPress iFrame plugins were made to use the HTML iFrame element that was deprecated on WordPress because of security reasons. This lets you customize the iFrame functionality with just some clicks. There is no need for any iFrame code anymore.

The plugins support shortcodes for inserting iFrame. They can be added in any section of the website like footer, widgets, and so on. The iFrame can showcase any other websites easily, and you can customize various attributes of it.

In this following, we are going to see the five best WordPress iFrame plugins:

iFrame

The iFrame plugin is going to offer great results. It has the same features as embedding an iFrame but is generated using a simple shortcode. Here is an example of how to use the shortcode for this WordPress plugin:

Advanced Responsive Video Embedder

This plugin is excellent for those that embed YouTube or Vimeo videos on their WordPress website.

With the help of this plugin, you can bring videos in a responsive and straightforward format to your site.

This WordPress plugin also adds a Video Embed button in the WordPress text editor, and with its help, you can easily embed videos from different websites.

Advanced iFrame

Another useful plugin is the Advanced iFrame plugin. It uses shortcodes and not the regular iFrame attributes and provides a UI to create those shortcodes.

As WordPress removes iFrame tags for security purposes, this plugin is the best. You can begin by installing the plugin, and then you’ll see that using an iFrame gets easier.

Auto iFrame

This is a solution to embed iFrame on a WordPress website. Check it out and take advance of it.

iFrame popup

The iFrame popup WordPress plugin is developed to show a specific web page in a popup window. It uses the URL of the web page to be displayed. Besides that, it also uses the jQuery fancy box extension to reveal the iFrame in a popup.

How to embed iFrame in WordPress without a plugin

To do this, the steps are not complicated at all. All you need to do to embed code for an iFrame is open and close the HTML tags and the URL of the web page that you want to integrate.

An iFrame code looks like this:

After that, if you want, you can bring more parameters to the tag. Defining the Window of the iFrame can be done using this:

  • Src – The source of the iFrame, this is a URL. If your site has SSL, you need to ensure all iFrames start with https://.
  • Width/Height– For height and Width of the iFrame Window, define values in Px
  • frame border – For displaying or hiding the Frameborder, use values ‘0’ or ‘1.’
  • Align – For determining the Window’s page alignment, Use values “left” “right” “right” “top,” “bottom.”
  • Scrolling – For disabling or enabling Scrolling inside the Window. Use values “yes,” “no” or

There are some limitations that we need to know about the source URL. If you use an iFrame, you can display just content from other sites that use the same Hypertext Transfer Protocols as yours.

So if your website starts with HTTPS, you can embed content from other third-party HTTPS sites. This also applies to sites that use HTTP; they can only embed URLs that contain HTTP.

FAQs about WordPress iframes

1. What is an iframe in WordPress?

A WordPress site can contain external material such as a web page, video, or document by using an HTML element called an iframe (short for inline frame). The iframe element inserts a window into your page that can contain content from another domain.

2. How do I embed an iframe in WordPress?

You can use the HTML code for the iframe element and paste it into your post or page editor in WordPress to embed an iframe. As an alternative, you can embed the iframe using a plugin that offers a shortcode or block. To prevent any security problems, it’s crucial to make sure the iframe’s source is reliable and safe.

3. What are the benefits of using iframes in WordPress?

The ability to include external material without leaving your WordPress site is one of the main advantages of using iframes in WordPress. This can be very helpful if you want to embed movies, forms, or other content kinds that WordPress does not normally accept. Iframes can also speed up a website’s performance by asynchronously loading external material.

4. Are there any security risks associated with using iframes in WordPress?

Absolutely, employing iframes in WordPress does have some possible security implications. Iframes allow external material to be incorporated within your website, thus it’s crucial to make sure the iframe’s source is reliable and safe. Iframes that are malicious can be used to steal user data or introduce malicious code. Iframes can also affect how well a website performs if they load slowly or have a big file size.

5. How can I make sure the iframe content is responsive on my WordPress site?

You can use CSS to set the iframe’s width to 100% and alter its height appropriately to ensure that the iframe content is responsive on your WordPress website. Moreover, you can make the iframe content responsive by using the “embed-responsive” class in Bootstrap or another comparable responsive framework.

6. Can I customize the styling of an iframe in WordPress?

Yes, you can use CSS to change an iframe’s styling in WordPress. To fit the appearance and feel of your WordPress website, you can change the iframe’s width, height, border, and other styling attributes. It’s crucial to check that the styling has no negative effects on the iframe’s functionality or the speed of the website.

7. How do I adjust the height and width of an iframe in WordPress?

The “width” and “height” elements in the iframe HTML code can be used to change the height and width of an iframe in WordPress. Alternatively, you can use CSS to change the iframe element’s width and height values. To prevent any display issues on various devices, it’s crucial to make sure the proportions are set correctly.

8. Can I embed a video using an iframe in WordPress?

Yes, WordPress allows you to embed videos using iframes. Iframe Embed codes are widely available from video hosting providers like YouTube, Vimeo, and Wistia and may be quickly added to your WordPress website. To use the video content, you must, however, be sure that you have the required authorizations and rights.

9. How can I troubleshoot issues with iframes in WordPress?

You can examine the source of the iframe to make sure it is safe and working correctly in order to troubleshoot iframe difficulties in WordPress. Also, you can examine the iframe and find any mistakes or problems with the content using browser developer tools. If the problem continues, you might need to get in touch with the website that created the iframe or look for a WordPress developer’s help.

10. Are there any WordPress plugins that can help with iframes?

Certainly, a number of WordPress plugins are available to aid with iframes. Embed Iframe and iframe are two common choices.

Ending thoughts on embedding a WordPress iFrame

In conclusion, knowing how to embed an iFrame code is very useful for any WordPress site owner.

This is even more true for somebody that relies on a lot of content to get the attention of its users.

If you enjoyed reading this article on how to embed a WordPress iframe, you should check out this one about how to change fonts in WordPress.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *