Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Custom search form - how do I get the posted values? WordPress

  • SOLVED

I've created a Custom Post Type called Properties. I want to search theses posts but found no way of including them in the results by the core search function so I decided to create a custom search form for my site.

This is how the form looks like:

<form class="search" method="GET" action="search-results">
<input type="hidden" name="rooms_from_value" class="rooms_from_value" value="" /
<input type="hidden" name="rooms_to_value" class="rooms_to_value" value="" />
<input type="hidden" name="space_from_value" class="space_from_value" value="" />
<input type="hidden" name="space_to_value" class="space_to_value" value="" />
<input type="hidden" name="price_from_value" class="price_from_value" value="" />
<input type="hidden" name="price_to_value" class="price_to_value" value="" />
<input type="hidden" name="country" class="display country" value="" />
<input type="hidden" name="type" class="display type" value="" />
<button type="submit">Search</button>
</form>


Why all the hidden fields? I've created non-form input elements to enhance the look and feel of the form. These elements then provide the hidden fields with the appropriate values when selected.

As for the action I want to take the user to a page called "search-results" and display the results there.
I'm pretty sure I know how to sort the results, I just can't fetch the values on the search-results site, I guess it's due to a conflict with the url rewrites. Any ideas?

Using WordPress 3.0 and the following plug-ins: WPML, Simple Fields

SOLVED

Answers (1)

2010-08-01

Lew Ayotte answers:

I may not be understanding your question...

When you submit the form you can use the $_GET['variable'] (where variable is the name of the input field) to get the values you want.

So for rooms_from_value, you'd use $_GET['rooms_from_value'];

Is that what you're asking?

Lew


Staffan Estberg comments:

Never mind, solved it.