gdrts_render_list_stars_review_args_rating

Developer Knowledge Level

This content is intended for WordPress developers, and it may require coding knowledge of WordPress, PHP, and JavaScript. Code examples provided here may contain errors or needs some additional coding. Make sure to test the code before using it on a live website!

Filter gdrts_render_single_stars_review_args_rating is used to filter the parameters used for the rendering of rating text in the rating list for Stars Review method templates. This filter has several arguments:

  • $atts: the array of parameters to filter
  • $render_object: the instance of the render object
  • $_rating: rating value
  • $_stars: max number of stars

Array $atts contains following elements:

  • before: HTML to show before the rating text.
  • after: HTML to show after the rating text.
  • rating: the string showing the rating. By default, this is: Rating: <strong>{$_rating}</strong>/{$_stars}.

Example to change rating/votes strings

add_filter('gdrts_render_list_stars_review_args_rating', 'custom__gdrts_render_list_stars_review_args_rating', 10, 5);
function custom__gdrts_render_list_stars_review_args_rating($atts, $obj, $_rating, $_stars, $_votes) {
  $atts['rating'] = sprintf('Rating: <strong>%s</strong>.', $_rating);

  return $atts;
}
0
0
756
Rate this reference

You are not allowed to rate this post.

Leave a Comment