WooCommerce remove specific attribute values from shop filter
WooCommerce remove specific attribute values from shop filter
I have two color values (from a product attribute) which are necessary for product variations but should be excluded from product filters. Can I remove these 2 color values via PHP in the functions.php? The two values should ONLY be removed from the filters, but not anywhere else.
The two values from the color attribute ("Farbe" = color) are "weiß/rot" and "weiß/blau".
Product filters: http://wordpress.p585884.webspaceconfig.de/shop/
The HTML:
<ul class="woocommerce-widget-layered-nav-list">
<li class="woocommerce-widget-layered-nav-list__item wc-layered-nav-term "><a class="awb-woo-attr" rel="nofollow" href="http://wordpress.p585884.webspaceconfig.de/shop/?filter_farbe=weiss-rot"><span class="awb-woo-attr-wrapper"><span class="avada-color-select"><span style="background-color: #862238"></span></span><span class="awb-woo-attr-name">weiß/rot</span></span><span class="awb-woo-attr-count">(1)</span></a></li>
<li class="woocommerce-widget-layered-nav-list__item wc-layered-nav-term "><a class="awb-woo-attr" rel="nofollow" href="http://wordpress.p585884.webspaceconfig.de/shop/?filter_farbe=weiss-blau"><span class="awb-woo-attr-wrapper"><span class="avada-color-select"><span style="background-color: #4d5f74"></span></span><span class="awb-woo-attr-name">weiß/blau</span></span><span class="awb-woo-attr-count">(1)</span></a></li>
</ul>
Screenshot of "Products / Attributes":
This jQuery solution I put together works, but I'd prefer to remove the unnecessary code before the page loads with PHP.
$('.woocommerce-widget-layered-nav-list__item .awb-woo-attr-name:contains("weiß/rot")').parents().eq(2).remove();
$('.woocommerce-widget-layered-nav-list__item .awb-woo-attr-name:contains("weiß/blau")').parents().eq(2).remove();
In case a PHP solution is not possible. How can I add these lines together? I've tried a "," in between without success.
Try the following jQuery code to combine the selectors
jQuery(function($) {
$('.woocommerce-widget-layered-nav-list__item .awb-woo-attr-name:contains("weiß/rot"), .woocommerce-widget-layered-nav-list__item .awb-woo-attr-name:contains("weiß/blau")').parents().eq(2).remove();
});
January 20, 2024
Turbo Multi-language Translator
Make the better internet purchasing globaly
Turbosify SEO Speed Booster
5.0 (7)•Free plan available
Get better conversions by improving store loading speed
Installed
Turbo Multi-language Chat - AI Customer service in one hand
January 20, 2024