If I have a form:

<form class="search" action="<?php echo site_url(); ?>/page-search?category=2" method="get">
    <input type="text" required name="search" placeholder="Search">
    <button type="submit" class="sprite-psuedo"></button>

How would I add the custom page-search,


global $query_string;

$query_args = explode("&", $query_string);
$search_query = array();

foreach($query_args as $key => $string) {
    $query_split = explode("=", $string);
    $search_query[$query_split[0]] = urldecode($query_split[1]);
} // foreach

$search = new WP_Query($search_query);

From Tutorial does not work. (Outputs nothing, it doesn't really seem to do anything). I tried too loop as well..

How do I process the form?


1 Answer 1


Try fetching as $_GET['category'].

Then u can use it whichever way u like

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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