Everyone at some point needs to have a sneaky little contact form in their sidebar, It’s a total ballache when customers want to be able to change it too.
So heres how we’re going to do this, what you’ll need is:
- A WordPress Install
- FTP Details (If plugins do not auto install)
- A Contact Form Plugin (Contact Form 7 I’ll be using)
- WP Hide Post Plugin
- 5 minutes of time
So we’re all ready? You will be kicking yourselves at how simple this will be.
First we install the plugins so:
Plugins > Add New > Search > Contact Form 7
Plugins > Add New > Search > WP Hide Post
And then install them.
Once you are done, click the new *Contact* button newly added to the bottom left of your wordpress nav.
After you have finished doing your shiny contact form copy the code.
It should look something like this:
[contact-form-7 404 "Not Found"]
Posts > Add New
Name it something like “SIDEBAR CONTACT FORM”
Paste your code in, on the WP Hide Post tick/cross all boxes to complete *hide* the post, and then click Publish as normal.
Hover over the post in the posts are to find its ID, ie
So your post is #12 for this.
We need to then go here:
Appearance > Editor: Then Click on: Sidebar (sidebar.php)
This will load up your sidebar.php file.
You then need to insert this code wherever you wish to have it show (ie at the top then right after the first <div id/class>
<!-- p= your post ID for the Contact form -->
<?php query_posts('p=12'); if(have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endif; ?>
Save, and that’s it, you’re done.
You client can alter and amend this sidebar form as per usual, and leaves you with no nasty coding at all!
This way is tonnes better than people who use the same code but link to page, since the contact page may have other written content such as telephone numbers etc which you won’t want!
Related Posts :
- WordPress Functions Add Post Featured Image
- WordPress: The plugin generated x characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin. *Fix*
- WordPress Error: Briefly unavailable for scheduled maintenance. Check back in a minute