1

I want to implement a search form like this: Loan Form

In my theme I have a custom post type called Data with the Year and Money custom fields.

I googled a lot but can't find a way to submit the user inputs to a place from where I can use WP_Query to populate the search result.

So, how to take user input from a form and use it to create a result page in WordPress?

And also please someone explain how the WordPress ?s= query works.

1 Answer 1

1

Creating custom search is not the easiest of tasks for beginners. You will need templates search.php and searchform.php - View Codex. You can then edit searchform.php and add any fields you need. When the user submits the form it will also add any extra fields you have - so your search url may look something like this /?s=1000&num=5&type=years (using the Loan Form example given in the question).

Once you have your form set up and submitting correctly you can use a hook such as pre_get_posts - View Codex combined with some Conditional Tags to test if is_search() then you can grab your extra inputs: $_GET['num'] $_GET['type'] and modify your query based on the values given.

That's the gist of it anyway.

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.