Skip Navigation

[Resolved] Split: Split: Filter Single Taxonomy via Checkbox – make custom checkbox filter as toggle button

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 5 months, 3 weeks ago.

Assisted by: Minesh.

Author
Posts
#2708164

This is awesome. Thank you. One finally request.

Would it be possible to instead of a checkbox for AND / OR to have a toggle / radio button.

UX wise it would be preferable.

#2708166

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

With your view:
- hidden link

I've adjusted the code under "Search and Pagination" section:

<div class="form-group">
  <label for="wpv-custom-and">[wpml-string context="wpv-views"]OR (Default) / AND [/wpml-string]</label>
	<div class="form-check">
      <label class="toggle">
        <input type="checkbox" id="wpv_control_checkbox_wpcf-and" class="js-wpv-filter-trigger form-check-input" name="wpv-wpcf-and" value="AND"  [set_field_checked url_param="wpv-wpcf-and" value="AND"]>
         <span class="slider"></span>
            </label>
        
        </div>
</div>

Added the following CSS code to CSS editor:

.toggle {
            position: relative;
            display: inline-block;
            width: 60px;
            height: 34px;
        }
         
        /* Hide the checkbox input */
        .toggle input {
            display: none;
        }
         
        /* Describe slider's look and position. */
        .slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: gray;
            transition: .4s;
            border-radius: 34px;
        }
         
        /* Describe the white ball's location 
              and appearance in the slider. */
        .slider:before {
            position: absolute;
            content: "";
            height: 26px;
            width: 26px;
            left: 4px;
            bottom: 4px;
            background-color: white;
            transition: .4s;
            border-radius: 50%;
        }
         
        /* Modify the slider's background color to 
              green once the checkbox has been selected. */
        input:checked+.slider {
            background-color: green;
        }
         
        /* When the checkbox is checked, shift the 
              white ball towards the right within the slider. */
        input:checked+.slider:before {
            transform: translateX(26px);
        }