Support » Developing with WordPress » Custom Multi Criteria Search

  • Hi,

    I am currently working on a client website. We have built a simple custom post type for displaying the companies properties that are available for rent.

    We have everything we require working, but now need to build out a custom search form, whereby a user can select multiple criteria before searching for properties.

    Example… Number of bedrooms: 2 | Price Range: 500-800 | Location: Manchester

    I am hoping somebody could point me in a direction of how to put something like this together. All of the available search criteria that the user can search with are custom taxonomies.

    Hopefully somebody can help.

    Thanks in advnce

    Dan

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Steve Stern (sterndata)

    (@sterndata)

    Forum Moderator & Support Team Volunteer

    This plugin provides a framework for that https://facetwp.com/

    Moderator bcworkz

    (@bcworkz)

    If you or anyone landing here is more interested in how one would code this instead of an immediate plugin solution, you need code that builds “tax_query” arguments from the criteria passed in the form.

    There’s a few ways to implement such code. I think a custom page template might be the simplest to implement. It can display the form as well as the results depending on the type of request — POST vs. GET. For each criteria, add a sub-array to the tax_query argument array.

    Once all the criteria has been collected into the tax_query array, include it in the overall WP_Query argument array. Instantiate a new WP_Query object, which runs the query and gets posts matching the criteria. Loop through the results and display as usual.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Multi Criteria Search’ is closed to new replies.