Hi,
Thank you for contacting us and I'd be happy to assist.
To achieve this, you'll first need to register a custom shortcode, which can return the number of the checked options from a 'checkboxes' type custom field.
add_shortcode( 'show_count_checkboxes_field', 'show_count_checkboxes_field_func');
function show_count_checkboxes_field_func( $atts ) {
$atts = shortcode_atts( array(
'id' => '',
'field' => '',
), $atts );
// slug of the field
$field_slug = $atts['field'];
// getting the field's output separated by,
$field_output = types_render_field( $field_slug, array( 'item' => $atts['id'], 'separator' => ',' ) );
// if there are some values returned, explode the string into an array and return the count
if(!empty($field_output)) {
$field_output_arr = explode(',', $field_output);
return count($field_output_arr);
}
else
{
// if no checked field values are returned, return 0
return 0;
}
}
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.
Next, please add "show_count_checkboxes_field" in the "Third-party shortcode arguments" section, at WP Admin -> Toolset -> Settings -> Front-end Content.
This new shortcode will accept two attributes, 'id' and the 'field', for example:
[show_count_checkboxes_field id='[wpv-post-id]' field='checkboxes-field-slug']
The above shortcode will return the number of the checked options from the field with the slug 'checkboxes-field-slug', from the current post ( as the 'id' is passed using the custom post's ID shortcode [wpv-post-id] ).
And the same shortcode can be used in a conditional statement to check for more than one checked option, like this:
[wpv-conditional if="( '[show_count_checkboxes_field id='[wpv-post-id]' field='checkboxes-field-slug']' gte '2' )"]
Two or more options checked!
[/wpv-conditional]
I hope this helps and please let me know if you need any further assistance with this.
regards,
Waqar