In version 2.4.0, we introduced Shop Filter theme options, with which you can manage filters on the shop page. You can show/hide filters and can display selected filter attributes.
If you are using theme, older than version 2.4.0, you can show/hide filters and can display selected attributes using custom coding.
Hide Filters:
To remove product filters on the shop page, add below code into the child theme’s functions.php file.
add_action( 'init', 'ciyashop_child_remove_shop_filter' );
function ciyashop_child_remove_shop_filter() {
remove_action( 'ciyashop_loop_filters', 'ciyashop_loop_filters_content' );
remove_action( 'ciyashop_loop_header', 'ciyashop_loop_active_filters' );
}
Hide Selected Attributes:
You can use WordPress filter hook to display selected attributes using below code.
//Remove attributes from Shop Filter on WooCommerce shop/archive page.
add_filter( 'ciyashop_shop_filter_exclude_attributes', 'ciyashop_child_theme_exclude_shop_filters' );
function ciyashop_child_theme_exclude_shop_filters( $attributes ){
// This variable contains complete list of attributes
$attributes
// You can exclude unrequired attributes from attributes variable.
unset($attributes['attribute-1']);
unset($attributes['attribute-2']);
// --- OR ---
// You can create a new array of selected attributes, which you want to display.
$attributes = array(
'color',
'size',
);
return $attributes;
}
You can find attributes list from Admin Panel > Products > Attributes > ‘Slug’ column in Attributes listing.