I am trying to change the out put of wc_get_rating_html using this filter

apply_filters( 'woocommerce_product_get_rating_html', $html, $rating, $count);

So far this function works and of course doesn't make any changes.

add_filter('woocommerce_product_get_rating_html', 'change_rating_output');
function change_rating_output($html){
    return $html;

My question is that how I can access those $rating and $count parameters inside the function change_rating_output so that I can change the $html as I need.

1 Answer 1


When you call add_filter(), set the fourth parameter to 3 (which is the number of parameters accepted by the callback function which in your case is change_rating_output()), and then change your change_rating_output() function so that it accepts the $rating and $count parameters:

add_filter('woocommerce_product_get_rating_html', 'change_rating_output', 10, 3);
function change_rating_output($html, $rating, $count){
    // Now do what you want with $rating and $count
    return $html;

See http://developer.wordpress.org/reference/functions/add_filter/ for further details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.