Skip Navigation

[Resolved] Filter grouping multiple values in a single selection

This support ticket is created 6 years 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by culturaI 6 years ago.

Assisted by: Nigel.

Author
Posts
#621155

Hello i'm creating a VIEWS, i have:

custom field type select: "tipo-di-corso"
possible values:
INTENSIVO, INDIVIDUALE, 2 PERSONE, FORMAZIONE CUOCO, FORMAZIONE PASTICCERIA, PROFESSIONALE BASE

In my VIEWS i'm using a select filter:
"tipo di corso" multiselect / string / IN / URL parameter / wpv-wpcf-tipo-di-corso_min

Until now everything working good, i can filter selecting a single or multiple values.

What i'm trying to do is add a possible selection that group multiple values:
TUTTI I CORSI DI LINGUA = "tipo di corso" in INTENSIVO or in INDIVIDUALE or in 2 PERSONE
TUTI I CORSI DI CUCINA = "tipo di corso" in FORMAZIONE CUOCO or in FORMAZIONE PASTICCERIA or in PROFESSIONALE BASE

It's possible with VIEWS?

Thanks

#621375

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

You will need to write some custom code to achieve this.

You will need to add the additional options to your select field (TUTTI I CORSI DI LINGUA and TUTI I CORSI DI CUCINA) using jQuery.

You then have two options.

Continuing with jQuery, when a user clicks either of these you can select the corresponding options for them.

Or you can use the wpv_filter_query PHP hook and manipulate the query arguments based upon that selection (https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query).

If that is not something you are comfortable with you could try one of the contractors listed here: https://toolset.com/contractors/

If you try it yourself and you run into problems let me know and I'll do what I can to help.

#622335

Resolved with this code jQuery:

$("#wpv_control_select_wpcf-tipo-di-corso > option:nth-child(1)").before($('<option value="["SERALE"]">TUTTI I CORSI DI CUCINA</option>'));
$("#wpv_control_select_wpcf-tipo-di-corso > option:nth-child(1)").before($('<option value="["SERALE"]">TUTTI I CORSI DI LINGUA</option>'));
$("#wpv_control_select_wpcf-tipo-di-corso > option:nth-child(1)").val(["INTENSIVO", "INDIVIDUALE", "SERALE", "2 PERSONE", "GRUPPO", "LINGUA + CUCINA", "DITALS", "CILS"]);
$("#wpv_control_select_wpcf-tipo-di-corso > option:nth-child(2)").val(["AMATORIALE", "PROFESSIONALE", "FORMAZIONE CUOCO", "FORMAZIONE PASTICCERIA", "PROFESSIONALE BASE", "AMATORIALE CONVIVIALE"]);

Thanks!

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