Skip Navigation

[Resolved] Find checked checkboxes with text search

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

Problem: I have several checkbox custom fields that store a yes or no value. I would like to be able to type the label of any checkbox into a text search field and find results that have that checkbox checked.

Solution: Relevanssi can help filter posts, including associated custom fields and taxonomy terms, using a text search. Unfortunately checkboxes are not supported in text-based searches. You can get around this if your checkbox field values match their labels. For example, if your checkbox for "Robotic" has a value "robotic" - see the screenshot attached. Add the checkbox fields to your post content, using Types or Views shortcodes. Hide them with CSS if you do not want the values to appear in your post. Then Relevanssi can will index those field values and include them in text searches. Here's an example of the post body content including hidden field values:

<div style="display:none;">
  [types field="industry-field-slug" separator=","][/types]
  [types field="where-in-the-world-field-slug" separator=","][/types]
</div>

Relevant Documentation:
https://toolset.com/documentation/user-guides/searching-texts-custom-fields-views-relevanssi/

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

This topic contains 2 replies, has 2 voices.

Last updated by marc-andre 4 years, 7 months ago.

Assigned support staff: Christian Cox.

Author
Posts
#618733

ok it's a question ask by my client....

The customer have some custom field like theses

client name : abc company inc.

industry we work in : (checkbox list)
-robotic : yes
-vision :no
-laser : yes
-camera : no

where in the world:
-america :yes
-europe:no
-asia:no
-Australia:no

and a description of my company :
we work with .....
and do this and that.....

-end of the company profile -

NOW i like to be able to search, but not necessary have a MULTIPLE field search....
i like to have only ONE field, that will search IN the description + where in the world + industry....

WHY, because if in the search field, the person type : europe, i what the search to get the profile of abc company inc. because in the taxonomy where we work in the wold, it's checked.... the big picture is the different checkbox listing will create a data word bank and be able to be search with only one search field....

HOW did i do this ?

#618837
Screen Shot 2018-02-22 at 4.54.07 PM.png

Hi, check out this document about the Relevanssi plugin. It can help filter posts, including associated custom fields and taxonomy terms, using a text search:
https://toolset.com/documentation/user-guides/searching-texts-custom-fields-views-relevanssi/

Unfortunately checkboxes are not supported in text-based searches. You can get around this if your checkbox field values match their labels. For example, if your checkbox for "Robotic" has a value "robotic" - see the screenshot attached. Add the checkbox fields to your post content, using Types or Views shortcodes. Hide them with CSS if you do not want the values to appear in your post. Then Relevanssi can will index those field values and include them in text searches. Here's an example of the post body content including hidden field values:

<div style="display:none;">
  [types field="industry-field-slug" separator=","][/types]
  [types field="where-in-the-world-field-slug" separator=","][/types]
</div>
#621542

I installed relelanssi and it came out with a nice output for my search... thanks a lot