0

I'm working in a site that allows to search for lawsuits about medical malpractice, the client wants to have a search form almost equal to the one in this site:

http://psychcrime.org/database/

All the information is stored in custom post types with custom fields, including the lawsuit, hospital and the doctor record.

I looked around for plugins but most of the advanced plugins I found are for custom taxonomies filters and not custom fields and some have the ability to search in custom fields but with only one input in the form instead of separated inputs for each possible field to search.

Is there a plugin that can achieve this layout and behaviour? If there is not what could be my best approach in creating this search form? I have never modified the wordpress search before.

We are using advanced custom fields plugin.

0

Custom fields are stored in post metadata, which is very expensive (slow) to query. Ideally, you would be better off re-coding the site to use custom taxonomies instead of custom fields. From there, search would be easier.

If you stick with ACF or other metadata, you can customize the search form and queries, but you'll be putting a lot of load on the server. At that point, it would be preferable to add a search service such as ElasticSearch or Swiftype. The client would pay for this monthly or annual service, but they'd be able to do all sorts of filtering and sorting without as much custom code, and everything would load much faster because you would then be querying an external service rather than the WP database.

  • I understand what you mean but some of the required queries like dates, numbers and relations cannot be solved with taxonomies so I will need the metadata, I will check the search services but this client has a limited budget so I might end up looking for something else. Thanks. – jeruki May 8 '18 at 21:55
  • 1
    Depending on their host they may have to up their hosting package in order to allow meta queries to work. Basically you need to set up a form that then queries posts like this: advancedcustomfields.com/resources/query-posts-custom-fields – WebElaine May 9 '18 at 13:34
  • I'm creating the form and submitting the data to try this right now, I will post back with results. – jeruki May 9 '18 at 21:48
  • 1
    You might also want to look into the Relevanssi plugin to see if it will search the fields you need. – WebElaine May 9 '18 at 21:57

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.