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>

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…

How do canonical links work in wordpress?

How do canonical links work in wordpress?

Canonical links are used to indicate the preferred URL of a webpage that has multiple versions or duplicates of the same content. This article explains canonical links in depth.

Share This
Martin Jarvis

Martin Jarvis

I typically reply within an hour

We're here Monday - Friday during UK working hours. Drop us an email and we'll get back to you.

Martin Jarvis
Hi. It's Martin here. How can I help you?
Start Chat with: