HTML iframe saves the day!

Converting existing websites with PHP scripting code to WordPress can cause parsing errors, problems picking up included files, or problems passing data from a form inside the included PHP file. Why not consider using HTML iframe?
2 Jan, 2010

We have recently been converting an existing website into a WordPress 2.9, so that a good CMS can be provided for the website owner and so they can now easily incorporate their blog into the main site. It’s a neat solution for most websites where the owner wants to keep their main site and blog(s) together on the same domain and where they want complete control over the style and content without having to ask a costly developer to make changes every time they introduce a new product.

The complication with this website was that a couple of the pages in the existing site had some considerable PHP scripting code which also needed to be incorporated into the new WordPress site. There are plenty of widgets around to allow you to insert blocks of PHP into WordPress pages, but none of these seemed to work for the code on the site we were converting, giving various parsing errors, problems picking up included files, and also problems passing data from a form inside the included PHP file. For completeness, the widgets we tried were Executable PHP Widget and Inline PHP.

After many hours struggling to get it working we eventually just stuck the PHP file inside an HTML iframe tag, set the width to 100% and the height big enough to cope with the entire page, and it worked like a dream first time. We have accepted that iframe isn’t universally supported, but it is a good, time-effective solution to the problem.

Here’s the code you need…

<iframe src=”yourphpfilename.php” width=”100%” height=”1500″ scrolling=”no” frameborder=”0″>
<p>Your browser does not support iframes.</p>
</iframe>

If you have managed to overcome this problem without iframe, please let us know.

1 Comment

  1. admin

    p.s. If you go down the iframe route to resolve this problem, don’t forget that any links contained within the php file in the iframe will open the linked document within the existing frame, which might not give you the effect you were after

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

You may also like…

Using WP-POLLS for my WordPress Polls and Surveys

Using WP-POLLS for my WordPress Polls and Surveys

Back in 2010 we started using the WP-POLLS plugin to add polls and surveys to one of our WordPress sites. 9 years on, is this still the best solution? Here’s our 2019 view on using polls and survey plugins in WordPress.

The importance of images in blog posts

The importance of images in blog posts

Website visitors really do respond more to content in posts that contain great images. Learn how to use images in your blog posts, and how to optimise them.

Share This

Was it a useful article?

A lot of work goes into providing information like this. If you have found this article helpful, please could you consider sharing it with your network for us?