On every page of my site I got a contact form that will send an email to the respective address. On this site also I've set the front page display to a static page.

The contact form will basically post to self and if successful will take the user to a new page, otherwise will anchor down to the contact form and display the error. But on the home page, be it any type of POST request, it will set the page to the posts page. Seems bizarre to me as it can be an empty POST request and still take the user back to the posts page but the URL won't change. This only happen if you do a POST to the homepage, all other pages work as expected.

Any ideas?

add_action( 'wp_head', 'process_contact_form' );
function process_contact_form() {

    if( isset( $_POST['submit'] ) && $_POST['submit'] ) {


add_shortcode( 'mini-contact', 'get_mini_contact' );
function get_mini_contact( $atts = array() ) {

        'title'   => 'Contact US',
        'button'  => 'Submit',
        'label'   => 'Message us',
        'subject' => 'Message'
    ), $atts));

    $html  = '';

    $html .= '<section id="quick-contact-form" class="home-solution">';
        $html .= '<div class="container">';
            $html .= '<header>';
                $html .= '<h2 class="aligncenter  type--bottom-space">' . $title . '</h2>';
            $html .= '</header>';

            $html .= '
                <form class="contact-form" method="post" action="">
                    <div class="row">
                        <div class="medium-5  columns">
                            <input type="text" name="name" class="form-contact__text" />
                        <div class="medium-5  columns">
                            <input type="text" name="email" class="form-contact__text" />
                    <div class="row">
                        <div class="medium-10  columns">
                            <label>Share your business problem today</label>
                            <textarea name="comment" rows="20" class="form-contact__textarea"></textarea>
                    <div class="row">
                        <div class="medium-10  columns">
                            <input type="submit" name="submit" value="' . $button . '" class="button  expand">
                    <input type="hidden" name="subject" value="' . $subject . '">

        $html .= '</div>';
    $html .= '</section>';

    return $html;

  • What are you front-page settings in Settings -> Reading? What are Front page displays, Front page, and Posts page? – Chip Bennett Feb 24 '14 at 16:32

When posting a form, if you use 'name' as an input name then there seems to be a problem with submitting.

Try changing:

<input type="text" name="name" class="form-contact__text" />


<input type="text" name="the_name" class="form-contact__text" />

Also, best to give your submit button a more unique name in case it conflicts with any plugins/themes - then check for the submission of that in your process_contact_form() function.

| improve this answer | |
  • How weird, it worked though. Any ideas on why it only affects the homepage? – WolfieZero Feb 24 '14 at 16:36

This may be a bit old but this post helped me find a similar issue. If you have an input name='search' it will also load a post page instead of reloading the static front page.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.