Harold Mansfield
10-27-2009, 09:55 PM
This is an oldie but a goodie.
Many times when you use WP as a static or informational website, you may disable the comments so as not to have that big comment box sitting below your posts or pages when you really aren't looking for comments.
The comments section has everything that a standard contact form has:
A field for "Name", "Email", "Website", and a box for additional comments..so why not use it ?
You can use it as a mini contact form that is visible below all of the content that you choose.
This takes just a little editing of the "comments.php" file of your theme.
First you want to look for the line of code that is the title (what makes it say "Comments"), it should look like, or similar to this:
<h3><?php comment_form_title( 'Comments', 'Comment %s' ); ?></h3>
Just change 'Comments' to "Contact Me" or what ever you want it to say.
You can leave the input fields the same, they will probably look something like this:
<?php else : ?>
[I]<p><input type="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> />
<label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p>
<p><input type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> />
<label for="email"><small>E-Mail <?php if ($req) echo "(required)"; ?></small></label></p>
<p><input type="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" tabindex="3" />
<label for="url"><small>Website (if Applicable)</small></label></p>
<?php endif; ?>
But you probably want to change the Submit Comment button. Look for this code a little further down:
<p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
<?php comment_id_fields(); ?>
and change "Submit Comment" (or whatever it says) to "Send" or what ever you want it to say...and save.
Now from your Dashboard ->Settings ->Discussion, set your comments to "Any User can comment" and "Comments Must be approved by Moderator", and that should do it.
Now you have a mini contact form that you can opt to display at the bottom of any page or post that should look like this (http://www.haroldmansfield.com/2009/10/wordpress-websites-and-blogs/) (in the post/page options), and you can see if you have any action from it in your dashboard the way you would normally see any comments left.
Many times when you use WP as a static or informational website, you may disable the comments so as not to have that big comment box sitting below your posts or pages when you really aren't looking for comments.
The comments section has everything that a standard contact form has:
A field for "Name", "Email", "Website", and a box for additional comments..so why not use it ?
You can use it as a mini contact form that is visible below all of the content that you choose.
This takes just a little editing of the "comments.php" file of your theme.
First you want to look for the line of code that is the title (what makes it say "Comments"), it should look like, or similar to this:
<h3><?php comment_form_title( 'Comments', 'Comment %s' ); ?></h3>
Just change 'Comments' to "Contact Me" or what ever you want it to say.
You can leave the input fields the same, they will probably look something like this:
<?php else : ?>
[I]<p><input type="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> />
<label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p>
<p><input type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> />
<label for="email"><small>E-Mail <?php if ($req) echo "(required)"; ?></small></label></p>
<p><input type="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" tabindex="3" />
<label for="url"><small>Website (if Applicable)</small></label></p>
<?php endif; ?>
But you probably want to change the Submit Comment button. Look for this code a little further down:
<p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
<?php comment_id_fields(); ?>
and change "Submit Comment" (or whatever it says) to "Send" or what ever you want it to say...and save.
Now from your Dashboard ->Settings ->Discussion, set your comments to "Any User can comment" and "Comments Must be approved by Moderator", and that should do it.
Now you have a mini contact form that you can opt to display at the bottom of any page or post that should look like this (http://www.haroldmansfield.com/2009/10/wordpress-websites-and-blogs/) (in the post/page options), and you can see if you have any action from it in your dashboard the way you would normally see any comments left.