filters – Remove extra line from the woocommerce widget

Question

I find a code to remove all filters at once. It works like a charm.
But it add extra line even there is no selected filters. https://prnt.sc/20e69c7

I want to remove this line if there is no active filter.

/*Clean active filters, Use this as a shortcode [cleanthemall]*/
add_shortcode( 'cleanthemall', 'cleanthemall' );
function cleanthemall() {
$filterreset = $_SERVER['REQUEST_URI'];
if ( strpos($filterreset,'?filter_') !== false | strpos($filterreset,'?min_price') !== false | strpos($filterreset,'?max_price')) {
 $filterreset = strtok($filterreset, '?');
 echo '<div class="clear-filters-container"><a id="woo-clear-filters" href="'.$filterreset.'">Clean All Filters</a></div>';
 }
}

0
roadlink 1 year 2021-11-21T14:29:17-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse