Skip Navigation

[Resolved] Filter by taxonomy and checkboxes custom fields not working

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

Problem: I have a custom search View with one taxonomy filter and several checkboxes groups filters. When I choose any of the checkboxes, no results are found.

Solution: There is a problem with the syntax for all the checkboxes filter control shortcodes. The code that was in place for the Arts & Culture field, for example, was like this:

[wpv-control-postmeta field="ac-types" type="checkboxes" url_param="ac-types" output="legacy"] 

However, the correct format for the field attribute should include the wpcf- prefix for the field slug, like this:

[wpv-control-postmeta field="wpcf-ac-types" type="checkboxes" url_param="ac-types" output="legacy"] 

I suggest adding the wpcf- prefix to each checkboxes group filter control shortcode slug.

Relevant Documentation:
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-control-postmeta
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-control-post-taxonomy

This support ticket is created 5 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
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 6 replies, has 3 voices.

Last updated by michaelB-32 4 years, 12 months ago.

Assisted by: Christian Cox.

Author
Posts
#1456427
Screen Shot 2020-01-13 at 7.55.05 AM.png

I am trying to: sort view results by custom field check boxes

Link to a page where the issue can be seen: hidden link

I expected to see: view results based on custom field selection

Instead, I got: No items found - Try changing your area to View All.

#1456805

Hi, can you open the Query Filter corresponding to this checkbox filter in the View Editor screen? If you cannot see the Query Filter panel, please scroll to the top right corner of the screen and click "Screen Options" to enable the panel. Please open all the toggles for this custom search Query Filter so I can see the settings, and take a screenshot. Then in the Search and Pagination panel, please copy the control shortcode related to this filter and paste it in your next reply, so I can see the configurations there as well.

Please include the screenshot and the filter control shortcode in your next reply, and I will take a closer look.

#1460459
Screen Shot 2020-01-15 at 10.09.57 AM.png

Hello Christian

Thank you for getting back to me. I have created an account for you on the staging website if it's ok for you to take a look? I created this yesterday so it should be current.

You can see the problem Dining page (link below). Attractions and Lodging sections have the same issue. The queries are similar on all the property sections as are the 'no results' results.

Thanks again,

Mike

#1462639

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Michael,

As Christian is currently unavailable, i'm covering for him.

Could you try changing the Fields Relationship comparison logic from an AND to an OR and try again?

Thanks,
Shane

#1462679

Hello Shane,

Yes, switching to OR did work to bring up a single selection. Will we be able to use the AND query?

Mike

#1467741

Hi, the problem here seems to be related to the filter control shortcodes. I'm not sure if this was a legacy implementation, or if there was some copy + paste issue, but the code that was in place for the Arts & Culture field, for example, was like this:

[wpv-control-postmeta field="ac-types" type="checkboxes" url_param="ac-types" output="legacy"] 

However, the correct format for the field attribute should include the wpcf- prefix for the field slug, like this:

[wpv-control-postmeta field="wpcf-ac-types" type="checkboxes" url_param="ac-types" output="legacy"] 

I made this change for you in the Arts & Culture field control shortcode, and I'm now seeing results appear when I select the Museum or Gallery AC Type. I suggest adding the wpcf- prefix to each filter control shortcode slug, to see if this fixes the problem completely. If not, I can take a closer look.

#1469707

My issue is resolved now. Thank you!