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.