If your search criteria involves more than one meta value, you’ll need to use the “meta_query” arg of WP_Query to specify what criteria to query for. It’s usage is kind of complex, but it’s also quite flexible and powerful. It’s likely you can define any combination of meta data criteria you might need. The challenge will be in formatting it correctly so the query returns the desired results. For meta_query documentation, find the “Custom Field” item in the WP_Query doc page’s table of contents. Follow the link. I cannot deep link directly to it from here. When I try, the landing scroll position is incorrect.
Another reason to use POST instead of GET method is it’s more suitable for forms with lots of field data. In PHP, instead of getting the passed form data from $_GET
you’ll need to use $_POST
or $_REQUEST
.
The reason I suggest the form’s action attribute takes one to a specific page that’s based on a custom template is it’ll make developing the right form handling code easier. To start with, the template could do:
`echo ‘
';
var_dump( $_POST );
echo '
‘;
This way you can see exactly what sort of data is coming from the form. You can remove this code once the search form is working correctly. Your task for this template will be to alter the sent data into a format that works for WP_Query.
With the right args supplied to WP_Query, your template can output the search results using the usual WP loop that outputs posts.