Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Filter Option for Unchecked Child Category by default on Selection Parent › Reply To: Filter Option for Unchecked Child Category by default on Selection Parent
Hi,
Do you mean like only opening the sub-categories, but not checking them?
I’m afraid there is no option to do that unfortunately, but it might be possible via a custom code though.
Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!
add_action('wp_footer', 'asp_api_sample_code');
function asp_api_sample_code() {
?>
<script>
jQuery(function ($) {
var settingsCheckboxToggle = function ($node) {
var $parent = $node;
var $checkbox = $node.find('input[type="checkbox"]');
var lvl = parseInt($node.data("lvl")) + 1;
var i = 0;
while (true) {
$parent = $parent.next();
if ($parent.length > 0 &&
typeof $parent.data("lvl") != "undefined" &&
parseInt($parent.data("lvl")) >= lvl
) {
if ($checkbox.prop("checked")) {
$parent.removeClass("hiddend");
} else {
$parent.addClass("hiddend");
}
} else
break;
i++;
if (i > 400) break; // safety first
}
}
$('.asp_option_cat input[type="checkbox"]').off('asp_chbx_change');
$('.asp_option_cat input[type="checkbox"]').on('asp_chbx_change', function (e) {
settingsCheckboxToggle($(this).closest('.asp_option_cat'));
var id = $(this).closest('.asp_w').data('id');
var instance = $(this).closest('.asp_w').data('instance');
ASP.api(id, instance, 'searchFor');
});
});
</script>
<?php
}
With this the checkbox states should stay the same as they are initially. If they are set to unchecked by default, then they should stay unchecked after clicking on the parent.