I want to have a filter for an attribute "brand" in the WooCommerce products section in the backend.
I am using the following code:
function custom_woocommerce_product_filters( $output ) {
global $wp_query;
$output .= wc_product_dropdown_categories(
array(
'show_option_none' => 'Filter by brand',
'taxonomy' => 'pa_brand',
'name' => 'pa_brand',
'selected' => isset( $wp_query->query_vars['pa_brand'] ) ? $wp_query->query_vars['pa_brand'] : ''
)
);
return $output;
}
add_filter( 'woocommerce_product_filters', 'custom_woocommerce_product_filters' );
This code displays the dropdown list for the filter with all brands inside it, but clicking on "Filter" does not return the filtered products. It simply shows all the products.
Can someone help please?
Thanks