Include forms and any PHP or HTML code in your WordPress pages & posts
I wanted to include a sign up form for iContact in my actual WordPress page and quickly found that this is not possible with the standard WordPress setup “out-of-the-box”. So I search around and found lots of plugins that claim to do what I needed but few actually worked correctly.
I finally found Exec-PHP which works perfectly. There was one small set of configurations I needed to do go through in order to make it work so I thought that I would share it with you.
First let me say that I’m running WordPress 2.5.1.
In order for Exec-PHP to work to insert iContact forms into pages you must disable your WYSIWYG editor. I know bummer, I like mine. The reason is that if you save your page (or post) after you insert your form or other code. WordPress automatically rewrites the code (effectively breaking the functionality of the code). This doesn’t happen if you disable the WYSIWYG (’visual’) editor but who want to be stuck always coding!
So here is what I did:
- Created a new user in WordPress ‘user’ configuration. (top right, by ’settings’ and ‘plugins’)
- I chose a username one character off from my normal user name and used the same password so that I could quickly and easily switch between the two.
- Now disable the ‘Visual’ editor in the option for that administrator that you have just created. I also chose to change the color scheme so that as I am working I will be able to easily tell which user I am logged in as.
Now I write my pages until I am satisfied with them. I then log out and back in as my alter ego (the one that has a disabled ‘visual’ editor). Insert my code and SAVE!
That’s it your done!
Oh except for one detail. For some reason that I don’t understand and don’t care to research, you must have your form in a separate file on your domain rather than inserted into the actual page. Now wait this isn’t a bit deal don’t worry. All that this means is that you insert your form code into example.php (or whatever) and then reference that form using this code in your post:
<?php require_once(ABSPATH. ‘example.php’); ?>
More about this in Exec-PHP’s extensive documentation
I hope that this is as helpful to you as it has been to me.
Tags: email marketing, wordpress