• I created a custom search form to find the posts by make use of wp_query.

    The form action is redirect to a custom page template where the custom wp_query running. The search form is using get method to passing the variable.

    <form method="get"  id="customsearch" action="<?php echo get_page_link( 3180 ); ?>">
    //form input here.
    </form>

    Somehow, the form was not redirected to the desired page, instead it went to homepage, when the permalink structure set to default.

    If I set the permalink other structure, like Numeric or Post name, it goes to the correct page, but url broken in paginated page. Eg:
    First page:
    www.example.com/search-page/?stringtosearch=xxxx?formsubmit=submit
    to
    www.example.com/search-page/page/2/?formsubmit=submit (the GET data stripped)

    Any idea why this happened?

Viewing 1 replies (of 1 total)
  • Thread Starter TC.K

    (@wp_dummy)

    Okay, Did some research, It seem I need to add query_vars to register the input name. But it still redirect me to the homepage after I registered the variables.

    I created i test form for this issues,like this:

    <form method="get"  id="text" action="<?php echo get_page_link( 3180 ); ?>">
    	<input type="text" name="testget" value="">
    	<input type="submit" class="submit" value="Search" alt="[Submit]" name="submit" title="Search" />

    and I register the variable into query_vars like this,

    function add_query_vars($aVars) {
    $aVars[] = 'testget';
    return $aVars;
    }
    add_filter('query_vars', 'add_query_vars');

    but still, it redirect to the homepage. Anyone know why is this happened?

Viewing 1 replies (of 1 total)
  • The topic ‘Form submission redirect to homepage’ is closed to new replies.