Skip Navigation

[Gelöst] Views filter checkboxes only return results for the first matched value

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
Create parametric search using checkbox filter so that it shows all items matching any of the checked values?

Solution:
There are two methods through which you can create parametric search using checkbox filter:

1. You can use “Checkboxes” field type for the checkbox filter. I have created a short video to show this, please see here: https://drive.google.com/file/d/0B5EmJQ1qcuyqc1ZQaGhSZmpQeHc/view?usp=sharing

2. Other solution is here, if your field type is different than the checkboxes:
https://toolset.com/forums/topic/parametric-search-keeps-displaying-wrong-results/#post-357800

This support ticket is created vor 6 Jahre, 10 Monate. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 3 Antworten, has 2 Stimmen.

Last updated by Joff vor 6 Jahre, 10 Monate.

Assisted by: Noman.

Author
Artikel
#528207
Page-Shot-2017-5-25 Toolset Views filter settings.png
Page-Shot-2017-5-24 Toolset Views filter checkboxes.png

I've got a Views filter using checkboxes (previously discussed at https://toolset.com/forums/topic/assigning-a-value-to-a-view-filter-using-a-checkbox-with-less-than-comparison/) where the options displayed by the checkboxes are numeric, e.g:

[ ] 1
[ ] 2
[ ] 3
[ ] 4
[ ] 5

To give some context, the checkboxes relate to the star-rating of a hotel.

When checking a single box, the search returns hotels matching that value. However when checking multiple boxes, the search only returns hotels matching the first value in the checked list.

The output of the query vars meta_query is:

   [meta_query] => Array
                (
                    [0] => Array
                        (
                            [key] => search_lowest_price
                            [value] => 2000,15000
                            [type] => NUMERIC
                            [compare] => BETWEEN
                        )

                    [1] => Array
                        (
                            [key] => search_duration
                            [value] => 10,30
                            [type] => NUMERIC
                            [compare] => BETWEEN
                        )

                    <strong>[2] => Array
                        (
                            [key] => hotel_rating
                            [value] => 2,3,5
                            [type] => NUMERIC
                            [compare] => =
                        )</strong>

                    [relation] => AND
                )

How can I return all items matching any of the checked values?

#528341

I should add, the strong HTML elements added to the query example above was my attempt to add emphasis to that portion of the query, and are not output on the site itself.

#528387

Noman
Supporter

Languages: Englisch (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Joff,

Thank you for contacting Toolset Support.

I have checked view filter using checkboxes and it is working as expected. Please make sure you are using “Checkboxes” field type for the Rating field. I have created a short video to show this, please see here: hidden link

Thank you

#528407

Hi Noman,

I'm unable to use the Checkboxes field type in this situation but I've found a solution at https://toolset.com/forums/topic/parametric-search-keeps-displaying-wrong-results/#post-357800

Thanks

Das Forum „Types Community Support“ ist für neue Themen und Antworten geschlossen.

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