Black Friday: Up to 40% off all plans!

Offer automatically applied at checkout
Days
Hours
Minutes
Seconds

FAQs

Find answers to common questions and step-by-step solutions.

Glossary

An alphabetical list of terms and their definitions.​

Video Library

Discover our tutorials

Preserving iframe Embeds in Imported Feed Content

Note: These documents refer to features and updates in the upcoming v5 release, which will be available soon. Some information may not apply to earlier versions. Stay tuned for the official launch announcement!

IN THIS ARTICLE
Learn how to keep iframe embeds, such as YouTube videos, when importing content from trusted RSS feeds.
Contents

By default, Aggregator sanitizes imported feed content to help keep your site safe. This means certain HTML tags that can introduce security risks, such as <iframe>, are removed during import.

In some cases, a trusted feed may include embedded content that you want to keep. For example, a feed item may include a YouTube video inside an <iframe> tag. If the iframe is removed, the imported post will not show the embedded video.

Aggregator includes a developer filter that allows you to opt in to preserving specific HTML tags and attributes during import.

When to Use This

Use this approach when:

  • You import content from a feed you trust.
  • The feed includes iframe embeds, such as YouTube videos.
  • The embed is missing from imported posts because the <iframe> tag is being stripped.
  • You are comfortable adding a custom code snippet to your site.

Do not allow iframe embeds from feeds you do not trust. Iframes can load external content and should only be allowed when the source is trusted.

Add the Snippet

Add this snippet to your site:

add_filter( 'wpra.importer.allowedHtmlTags', function ( $tags ) { 
      $tags['iframe'] = array( 
         'src' => true, 
         'width' => true, 
         'height' => true, 
         'frameborder' => true, 
         'allow' => true, 
         'allowfullscreen' => true, 
         'loading' => true, 
         'title' => true, 
      ); 

      return $tags; 
} );

After adding the snippet, import a new item from the feed and check the imported post. The iframe embed should be preserved if it is included in the original feed content.

Note: If you are unsure how to add the code snippet to your site, see Adding Custom Actions and Filters.

Important Note

  • This snippet allows iframe tags during the import process for all feed sources on the site. Only use it if you trust the feeds being imported.
  • This change affects newly imported content. If a post was already imported before the snippet was added, the missing iframe will not automatically appear. You need to re-import the item.

If the Embed Still Does Not Appear

Check the following:

  1. Make sure the snippet is active on your site.
  2. Confirm that the original feed item includes an iframe.
  3. Import a new item or re-import the affected item.
  4. Check whether another plugin or custom code is removing iframe tags.
  5. Make sure your site is using Aggregator version 5.2.1 or later. The wpra.importer.allowedHtmlTags filter was added in version 5.2.1.

Can I Allow Other Tags?

Yes. Developers can use the same filter to allow other HTML tags and attributes.

Only allow the tags you need, and only for feeds you trust.

GIVE FEEDBACK

Was this article helpful?

Still stuck?