I am looking for a way to default open the subcategories in the shop sidebar. Thank you.
Hi,
You can use the following CSS code:
.wc-block-product-categories .wc-block-product-categories-list li ul{ display: block!important; }
However, notice that the subcategories will be opened by default and will be unclosable.
Best regards
perfect thank you
I would also like that when you click on it, it can close
than you very much
There is no option to do that with CSS.
You would have to modify theme files or write a custom JS.
and you don't have any JS can do it? thank
i tryed this , but this not work :
document.addEventListener('DOMContentLoaded', function() {
var categories = document.querySelectorAll('.wc-block-product-categories .wc-block-product-categories-list > li > a');
categories.forEach(function(category) {
category.addEventListener('click', function(e) {
e.preventDefault();
var subList = this.nextElementSibling;
if (subList && subList.tagName === 'UL') {
if (subList.style.display === 'block' || subList.style.display === '') {
subList.style.display = 'none';
} else {
subList.style.display = 'block';
}
});
No, we do not provide support with such customization.
Comments
Hi,
You can use the following CSS code:
However, notice that the subcategories will be opened by default and will be unclosable.
Best regards
perfect thank you
I would also like that when you click on it, it can close
than you very much
There is no option to do that with CSS.
You would have to modify theme files or write a custom JS.
Best regards
and you don't have any JS can do it? thank
i tryed this , but this not work :
document.addEventListener('DOMContentLoaded', function() {
var categories = document.querySelectorAll('.wc-block-product-categories .wc-block-product-categories-list > li > a');
categories.forEach(function(category) {
category.addEventListener('click', function(e) {
e.preventDefault();
var subList = this.nextElementSibling;
if (subList && subList.tagName === 'UL') {
if (subList.style.display === 'block' || subList.style.display === '') {
subList.style.display = 'none';
} else {
subList.style.display = 'block';
}
}
});
});
});
No, we do not provide support with such customization.
Best regards