Content sharing is fairly a common practice. However, featuring another creator’s content on your WP site has potential legal ramifications.
In a nutshell, iFrame is a fruitful way to embed a web page into the content of another page. There are two situations where iFrames are generally useful.
First, when you wish to share content that doesn’t belong to you. Second, you want to share large files using iFrames. Simply, you can display a file’s content on your site without having to host it in your WordPress Media Library using iFrame.
There are various scenarios in which you want to use an iFrame. If you want to include Web/Media content on your website or to load an Ad on your website, you can use the iFrame outstandingly. You can include these iFrames to your WordPress website through the UI dialog box and make your web page content more attractive and eye-catching.
But what if you are a programmer and trying to migrate a client’s website from an old platform to a new CMS? When you want to insert iFrames programmatically, WordPress doesn’t by default allow you to do that for various security reasons. However, you want to do it at any cost. You know all the security measures and are well-aware of the consequences. So, what to do? In that case, just follow the code block section shared here and do it effectively.
//This is used to suppress wordpress default filters while post content saving. Iframes are generally not saved while wp_insert_post.
//So do this
remove_filter('content_save_pre', 'wp_filter_post_kses');
remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
//your wp_insert_post
add_filter('content_save_pre', 'wp_filter_post_kses');
add_filter('content_filtered_save_pre', 'wp_filter_post_kses');
Now that you add this iFrame section into your WordPress coding; run the simulation and it works perfectly fine for you.
There are other ways to embed content as well, but iFrames are easily the best medium for beginners to experience level as they’re extremely easy to set up.
Find this useful? Yes/No – do let us know!