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_like_this_args_rating is used to filter the parameters used for the rendering of rating text in the single rating block for Like This 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
  • $_user_has_voted: number of votes

Array $atts contains following elements:

  • before: HTML to show before the rating text.
  • after: HTML to show after the rating text.
  • show_votes: show number of votes.
  • likes: the string showing the rating. By default, this is can have various value, depending on the current user vote:
    • Only current user voted: You like this.
    • Current user and more voted: You and %s other like this.
    • Users voted: %s person voted.

Example to change likes string

add_filter('gdrts_render_single_like_this_args_rating', 'custom__gdrts_render_single_like_this_args_rating', 10, 4);
function custom__gdrts_render_single_like_this_args_rating($atts, $obj, $_rating, $_user_has_voted) {
  if ($_user_has_voted) {
	if ($_rating == 1) {
	  $atts['likes'] = __("You like this.", "gd-rating-system");
    } else {
      $_rating_mod = $_rating - 1;

      $atts['likes'] = sprintf(_n("You and %s other like this.", "You and %s others like this.", $_rating_mod, "gd-rating-system"), $_rating_mod);
  } else {
    $atts['likes'] = sprintf(_n("%s person likes this.", "%s people like this.", $_rating, "gd-rating-system"), $_rating);

  return $atts;
Rate this reference

You are not allowed to rate this post.

Leave a Comment