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…

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


Submit a Comment

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

You may also like…

Why choose WordPress – what’s the fuss?

Why choose WordPress – what’s the fuss?

We decided to become WordPress experts because we believe it to be a great, cost-effective platform for small- and medium-sized businesses. It’s packed full of functionality and a great content management system – in fact, WordPress started out as a blogging platform, but developed into much more.

Share This