Dont use the plugins for contact us page in wordpress which will and unwanted code to your site.we given the simple code snippet for create contact us template page in wordpress.

create contact us template page in wordpress

Contact us page is important for every website. Many wordpress developers use the contact7 wordpress plugin for creating the contact page.

Dont use the plugins for contact us page in wordpress

If you use any contact us plugin then your site became little bit slow. because due to database custom quires you will some bandwidth.  My suggestion is use simple php code for that.

You need to just create the contact.php page in your wordpress theme folder and put the following code in that file.

Template Name: Contact Us
 $error = "";
 $error .= "<p>Please enter your name</p>";
 $error .= "<p>Please enter a valid email address</p>";
 $error .= "<p>Please enter a message</p>";
 $error .= "<p>Please enter a message</p>";
 $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(); ?>

 <section id="primary">
 <div id="content" role="main">

<div id="archives">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
 <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
 <h1><?php the_title(); ?></h1>
 <?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 = "Contact Us" /></div>

 <?php } ?>
 </div><!-- .entry-content -->
 </div><!-- #post-## -->
 <?php endwhile; ?>

 </div><!-- #content -->
 </section><!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

create contact us template page in wordpress

create contact us template page in wordpress



If you need more information about then check following articles.

Written by WPAPI

My name is Purab Kharat, Here is my Personal Blog: Work as an Senior Technical Lead at Smartsourcing Global Pvt Ltd in Princeton, NJ, USA. I contributor of many wordpress plugins and Drupal Modules. I am core developer of Drupal. Connect to purab on LinkedIn or Follow @purab on Twitter or Follow me on Google+ or Write Mail to or Chat with me on Skype : purabdk

This article has 4 comments

  1. TheMannyMan Reply

    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!

  2. simon Reply

    this works great thank you, but in the boxes appears the code. how do i stop the code form shoing the the boxes?

  3. Aundrea Reply

    Ԝonderfuսlly writtren peice wigh gopd pointѕ through out.
    Congraulations yooս now have a regullar νisitor haha

Leave a Comment

Your email address will not be published. Required fields are marked *