scopeak
scopeak

Reputation: 545

How can I edit the Woocommerce product widget html class?

I would like to add a class to the existing woocommerce product widget.

The file '/includes/widgets/class-wc-widget-products.php' has the following filter.

echo apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' );

Is there a method that I can edit the html <ul class="product_list_widget"> in that filter within my theme?

Upvotes: 1

Views: 1464

Answers (1)

hemnath mouli
hemnath mouli

Reputation: 2755

this seems to be straight. Add the following in your functions.php

add_filter( "woocommerce_before_widget_product_list", "edit_product_widget_list", 1, 1 );

//$old_html contains -> <ul class="product_list_widget">
function edit_product_widget_list ( $old_html ) {
    return '<ul class="my_own_class_here">'; // change your class here
}

Good luck :)

Upvotes: 1

Related Questions