Skip Navigation

[Resolved] How to filter by more than one checkbox

This thread is resolved. Here is a description of the problem and solution.

Problem:

The metafield is not created by Types plugin but a standard worpress metafield, values are separated by comma
When searching by checkboxes, a single checkbox is checked, it return the good result, but more one is checked no results

[wpv-control-postmeta display_values="Famille,Noces/Anniversaire de mariage,Pension,Golf,Spa,Remise" values="Famille,Noces/Anniversaire de mariage,Pension,Golf,Spa,Remise" field="attributs_offres_intranet_wp" type="checkboxes" source="custom" url_param="wpv-attributs_offres_intranet_wp" output="legacy"]

Solution:

The checkboxes field in Views custom search form does not support the custom field you mentioned above:

but a standard worpress metafield
values are separated by comma

In you case, I suggest you try with some custom PHP codes, when user submit the search form, use filter hook "wpv_filter_query" to trigger a PHP function, in this function, get the "wpv-attributs_offres_intranet_wp" value submitted by user:

http://php.net/manual/en/reserved.variables.post.php

Apply them into the Views query one by one:
https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters

See the example codes

https://toolset.com/forums/topic/how-to-filter-by-more-than-one-checkbox/#post-631805

Relevant Documentation:

This support ticket is created 6 years, 8 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 20 replies, has 2 voices.

Last updated by Luo Yang 6 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#641434

Hello
It is the same probelm, the metafields are comma separated
To see the url you MUST BE CONNECTED

Thank you

#641525

I am trying to help you to setup the custom codes, but you did not provide the detail steps.

How can I "BE CONNECTED"?
Please provide detail steps.

And have you checked the custom field "attributs_offres_intranet_wp" value of above two posts?
That will help a lots!

#641554
front.png
db.jpg
backend.png

Hello
Sorry, hope with theses images it will be more clear
Thank you

#641574

Please have a look at your own screenshot:
hidden link

For the same post(ID 609), post title "Casadelmar – Corse", there are two records for custom field "attributs_offres_intranet_wp",
1) Famille, Golf
2) Golf, SPA

So it is expected result that Views will output post (ID 609) as the result, when you filter by Famille + Golf + SPA

Hope it is clear.

#643468

Thank you very much

#646153

You are welcome