Skip Navigation

[Resolved] Custom Filter using Checkbox

This support ticket is created 4 years, 3 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 4 replies, has 2 voices.

Last updated by Luo Yang 4 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#1813023

Tell us what you are trying to do?
I am trying to create a view that will return all CPTs that do not have a checkbox checked. I am not storing 0 to the database.

Is there any documentation that you are following?
https://toolset.com/documentation/legacy-features/views-plugin/checking-fields-and-other-elements-for-emptynon-empty-values/

I followed the above and left the constant empty. The view did not return any CPTs including the ones with no checkbox checked.

Is there a similar example that we can see?

What is the link to your site?

rvrally.net

#1813601

Hello,

You can use shortcode [types field="my-checkbox"][/types] to get your custom checkbox field value, and use it in wpv-conditional shortcode as condition, for example:

[wpv-conditional if="( '[types field="my-checkbox"][/types]' eq '' )"]The checkbox field "my-checkbox" is empty[/wpv-conditional]

More help:
https://toolset.com/documentation/legacy-features/views-plugin/using-shortcodes-in-conditions/

#1814397

Luo,

Judging by the link, this is a legacy feature for the old views plug in. I am running the new views and do not see any way to insert the shortcode above. I assume that I need to run the legacy views plug in? If so, can I run both on the same site?

#1814429

Luo,

OK. I figured out how to use the old views plug-in in my new Blocks environment. I have set up the filter in the old views plug in to this:

[wpv-filter-start hide="false"]
[wpv-filter-controls][wpv-conditional if="( '[types field="my-checkbox"][/types]' eq '' )"]The checkbox field "my-checkbox" is empty[/wpv-conditional][/wpv-filter-controls]
[wpv-filter-end]

The last issue - how do I find the "my-checkbox" name?

#1815817
my-checkbox.JPG

When you create the custom field, there is an option "Field slug", you can use it in Types shortcode, see my screenshot.

More help:
https://toolset.com/course-lesson/creating-custom-fields/