Every wordpress site is need to contact us page for there website or blog. All the people use the wordpress plugin for creating the contact us page. When you install the wordpress plugin that will install some extra code to your wordpress site. After using wordpress plugin you need some customization in that plugin due to UI. You need R&D time and development time.
In this article I will show how you can create the contact us page with out any wordpress plugin. Using following code you can create the contact us form very easily.
First create contact-us.php page in your wordpress theme folder and put following code in that file.
<?php
/*
Template Name: Contact Us
*/
if($_POST[sent]){
$error = "";
if(!trim($_POST[your_name])){
$error .= "<p>Please enter your name</p>";
}
if(!filter_var(trim($_POST[your_email]),FILTER_VALIDATE_EMAIL)){
$error .= "<p>Please enter a valid email address</p>";
}
if(!trim($_POST[your_message])){
$error .= "<p>Please enter a message</p>";
}
if(!trim($_POST[your_subject])){
$error .= "<p>Please enter a message</p>";
}
if(!$error){
$email = wp_mail(get_option("admin_email"),trim($_POST[your_name])." sent you a message from ".get_option("blogname"),stripslashes(trim($_POST[your_message])),"From: ".trim($_POST[your_name])." <".trim($_POST[your_email]).">\r\nReply-To:".trim($_POST[your_email]));
}
}
?>
<?php get_header(); ?>
<div id="container">
<div id="content" role="main">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1><?php the_title(); ?></h1>
<div>
<?php if($email){ ?>
<p><strong>Message succesfully sent. I'll reply as soon as I can</strong></p>
<?php } else { if($error) { ?>
<p><strong>Your messange hasn't been sent</strong><p>
<?php echo $error; ?>
<?php } else { the_content(); } ?>
<form action="<?php the_permalink(); ?>" id="contact_me" method="post">
<input type="hidden" name="sent" id="sent" value="1" />
<div id="form">
<div id="lebel">Your Name (required)</div>
<div id="input-field"><input type="text" name="your_name" id="your_name" value="<?php echo $_POST[your_name];?>" /></div>
<div id="lebel">Your Email (required)</div>
<div id="input-field"><input type="text" name="your_email" id="your_email" value="<?php echo $_POST[your_email];?>" /></div>
<div id="lebel">Subject</div>
<div id="input-field"><input type="text" name="your_subject" id="your_subject" value="<?php echo $_POST[your_subject];?>" /></div>
<div id="lebel">Your Message(required)</div>
<div id="input-field"><textarea name="your_message" id="your_message"><?php echo stripslashes($_POST[your_message]); ?></textarea></div>
<div id="lebel"> </div>
<div id="input-field"><input type="submit" name = "send" value = "Send email" /></div>
</div>
</form>
<?php } ?>
</div><!-- .entry-content -->
</div><!-- #post-## -->
<?php endwhile; ?>
</div><!-- #content -->
</div><!-- #container -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Then go to your wordpress admin panel. Create page called contact us. In Right side panel you will find the “page attribute” section. From template drop down choose the Contact Us option. and create the contact us page.

WordPress uses the wp_mail() function for sending the email. all wordpress plugin also use the wp_mail() function for sending the email.
If you are having issues with sending the email with this function then you should use the different SMTP mail server for sending mail.
For sending email through SMTP in detail you should check the following article.
http://wordpressapi.com/2010/11/24/send-smtp-email-wordpress-plugin/
With this code you can write your own CSS for styling the contact form as per your wordpress theme. If you are having any issues or question about this script then please write to me.
Incoming search terms:
- wordpress contact us page
- how to create contact us page in wordpress
- wordpress email form without plugin
- create contact form wordpress without plugin
- how to create a contact us page in wordpress
- create contact form wordpress
- wordpress custom forms no plugin
- wordpress contact without plugin
- contact form wordpress without plugin
- WORDPRESS AWESOME CONTACT US PAGE
- how to write code of contact us form in wordpress
- how to to insert php code to wordpress page with plugin
- how to make a contact us on wordpress
- how to implement contact us without plugin in wordpress
- contact us in wordpress without plugin
- create a contact form wordpress
- how can i add php web form in wordpress
- create custom plugin of contact form in wordpress
- create contact us plugins in wordpress
- create contact us form plugins in wordpress
Howdy. Great work once again. I enjoyed reading your blog for the reason that the writers often post great pieces of information. Awesome article.I plan to add this blog to my faves. I am planning to subscribe to the blog feed too. Just got a brand new cell too. Does anyone own the galaxy??? It is awesome..
Good post….thanks for sharing.. very useful for me
Hi. Pretty intriguing web-site. I discovered it on Yahoo. I’ll definately propose it to my friends. Please preserve up the wonderful operate.
Why do notyou guys just come out and say we appreciate uncomplicated logos!???
Could I make a suggestion? I do think youve got something great here. But what if you also offered a few references towards a site which supports what you are saying? Or perhaps you may give us some extra information to look at, whatever would connect what you were saying, something more concrete?
I revelled reading it. I require to read more on this subject…I am admiring the time and effort you put in your blog, because it is apparently one great place where I can find lot of reusable info..
Hello, you used to write fantastic, but the last several posts have been kinda boring? I miss your great writings. Past several posts are just a little out of track! come on!
nice post.. i was searching for it. i have using plugins they rally overload our site. thanxx
Cara obrigado pela dica, estou usando em meu site!
How do I send this information to a databse instead – basically I would like to send to database, receive a notification and also send email to the person that contact me. Could this be achieved at one go? Thanks!
Intriguing post. I have been searching for some good resources for solar panels and discovered your blog. Planning to bookmark this one!
Great stuff. Thanks for this!
Awesome post. I so good to see someone taking the time to share this information
I’ve been checking your blog for a while now, seems like everyday I learn something new
Thanks
Thanks for posting. Good to see that not everyone is using RSS feeds to build their blogs
Of course, what a great site and informative posts, I will add backlink – bookmark this site? Regards, Reader
This post makes a lot of sense !
I REALLY liked your post and blog! It took me a minute bit to find your site…but I bookmarked it. Would you mind if I posted a link back to your post?
Awesome post. I so good to see someone taking the time to share this information
Great read. Thanks for the info!
Hello, this is my first time i visit here. I found so many interesting in your blog especially on how to determine the topic. keep up the good work.
I’ve been checking your blog for a while now, seems like everyday I learn something new
Thanks
This post makes a lot of sense !
The contact form doesnt send the email to the desired email address of the blog
Thanks for sharing this article. But it would have been great if you could have shared how exactly the “Contact Us” page will look. And will i need to write something also while i am creating the page ?
Hi Dear, I have followed your steps in my localhost wordpress admin… But i cant able to send a mail… I think it sould be work in server only….
I cannot able to send email from windows box. You need sendmail server on your machine or you need to install send-smtp-email-wordpress-plugin
hello dear i am also use wp_mail in contact-us.php file… But i don’t know why i cant able to send an email to admin…. Here i echo all the values in wp_mail(values) but i didn’t echo wp_mail()…. please anyone help me…
did you configured the SMTP settings in plugin. First test your smtp setting.