Skip Navigation

[Resolved] link value of different custom fields to filter object

This support ticket is created 3 years, 9 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by sanderB 3 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#1687423

I want to make a filter using custom fields that needs to do the following.
The "object" that I want to filter are destinations like countries. I want to make a custom field for "month","temperature","consitency", but the values need to be somehow linked. I'll try to explain :
As a user I want to be able to:
- select a month, for example january(consitency needs to have a specific value for each month and will have a default setting, like for instance 8/10)
->result is that my page now only shows destinations that have a consistency of 8/10, during the selected month of January.
- next I further filter on temperature : example 20°C
-> result is that my page now shows destinations that have a consistency of 8/10 during my selected month of January and have an average temperature of 20°C.
- next, as an option, I want to release the consistency paramter to let's say 7/10, so my page now also shows all destinations that have a consitency of 7/10 during the selected month of January with an average temperature of 20°.

In other words, the value of a custom field needs to be related to the value of another custom field, for example :
the object (the destination) Portugal has a custom field "month" which is a dropdown with every month in the list,
it also has a custom field temperature, but the value of this custom field needs to be related to the value of the other custom field for month. Same for consistency. Example

Portugal:
- custom field "Month" : January -> custom field "temperature" : 20°C -> custom field "consistency" 7/10
- custom field "Month" : February -> custom field "temperature": 25°C-> custom field "consitency" 8/10

and so on. and of course this works on both directions
The custom field for "Month" could be considered as a parent while the others as children, but it doesn't have to be like that

Is there a way to do this ?

#1688143

Hello, it sounds like you would like to be able to create a custom search View with several filters based on custom fields. The default value of some filters should be variable based on the selections in other filters, so when you select a specific month for example, the default selection for consistency will be option A but if you select a different month, the default selection for consistency will be option B. That type of customization is not a built-in feature of Views, so it would require some custom coding using JavaScript. Custom front-end filters aren't supported here in the support forums because there is no real JavaScript API available for filters, only a few event hooks you can use to listen to change events and search events. A developer with some understanding of JavaScript and HTML might be able to get this to work for you.

The only similar solution built-in to the system is a feature that will update each filter's options list when another filter has been selected, so that the options shown in the other filters will always produce some results. In other words, if consistency 2/10 is not selected for any month or temperature combination when Portugal is selected, that option will not be displayed in the consistency filter once Portugal has been selected. You will have the option to enable or disable this feature when building the View.

One thing you could do as an alternative solution that does not require custom code is to build out links to the different monthly default configurations for each country, and display those links to your Users as a quick navigation menu. Custom Search Views can be configured to respond to URL parameters, and each filter option can contain a different URL parameter/value pair. So once you know the parameters and configurations for each month and its corresponding default values, you can create links directly to those URLs so your visitors do not need to select each individual filter option (though they could always manually change the filters if they want). So using your example above, you could create a list of links for each country and include the required URL parameters in the HTML for each link, similar to the URLs below:

Portugal: 
- January (<em><u>hidden link</u></em>)
- February (<em><u>hidden link</u></em>)
- March (<em><u>hidden link</u></em>)
...

When the User clicks one of these links, they will be directed to a page containing the search results and the filters preselected. Then they can adjust the filters if they want to see other results.

Let me know if you have questions about this workaround and I can give you more direct guidance.

#1691009

hi Christian, thanks for putting the time into this. I really wanted to make sure there's no "out of the box" solution, so I don't lose to much time looking for it. I'll check you're workarounds, but as I'm working on this project on the side I can't really tell when I will finally find some time to work on it.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.