Skip Navigation

[Resolved] How do I search two custom fields with 1 drop down select?

This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 3 replies, has 2 voices.

Last updated by Beda 6 years, 6 months ago.

Assisted by: Beda.

Author
Posts
#819534

I have a classified site with 2 fields 1st field is "Breed of Cow" 2nd field is "X Breed of Cow"

I have a view with a custom search drop down filter that can search the first field, but I want it to include the results from the 2nd field also. How can I do this?

If this cant be done can is there a workaround: For example I have a post title which is made up of the two breeds, can I create a drop down that searches the title (unfortunately I don't want to use a text search but it does work) I need users to select from a pre determined breed

any help would be appreciated

#823472

It's not possible

Each Search input in the View has a unique function, data source and data destination.
It cannot be "bundled" by several fields.

What you can always do, is apply a Free Text Search and use Relefvannsi to index your simple Toolset Custom Fields - this will allow you to search in all content but using just one text input field:
https://toolset.com/documentation/user-guides/searching-texts-custom-fields-views-relevanssi/

Searching by Post Native Data like the title is only possible in the Free text Search and not as a Dropdown or similar.

#823991

So I actually managed to do it by adding a quiry then made them both the same url parameter. but it seemed to stuff the other filters up. Are you sure there is no way to do this at all?

#824249

How would you query the second Custom Field?

If you do not pass it's values to the Filter, then the Filter cannot filter by it.
Just adding a Query Filter by this field does not help, as the Custom Filter must submit the value you chose to the URL parameter.

If you manage to combine the 2 fields in the Search input, then probably you can as well neglect one of both fields and add both pieces of information to one field only, as then the information would not differ that much to put it in different fields.

You can, of course, alter your query with our API and pass arguments or filter the posts additionally, the reference for the API is here:
https://toolset.com/documentation/programmer-reference/views-filters/

But it is not possible to add values from one field to another field's Custom Search input with those hooks.
You could however filter the output additionally by any value conditionally to what you select, for example.