FAQ

What are the requirements?

  • You need at least WordPress 3.7 running on your self-hosted installation.
  • PHP > 5.3 should run on your webserver.
  • Your theme needs to use WordPress’ internal comment template functions. If your theme is doing some special things it will not work.
  • The plugin will not work with plugins that load the comment section via AJAX.

Can I show the total number of rates a comment has got?

At the moment this is not possible right from the settings page. But you can request a function if you want to see this in one of the next functions.

If you don’t mind adding another custom plugin check the code below that can show the actual numbers.

What are the filters and actions that I can use to hook into the plugin?

Since version 1.0:

  • Filter: wpbcr_output_elements
    • Parameters:
      • (array) $elements
      • (object) $comment
    • Here you can change the source code of the outputted html.
  • Filter: wpbcr_comment_rating_classes
    • Parameters:
      • (array) $classes = array( ‘wpb-comment-rating’ )
      • (object) $comment (since v. 1.1)
    • Allows to add your own CSS classes to the comment rating.
  • Filter: wpbcr_output_html
    • Parameters:
      • (string) $content
      • (object) $comment
    • Allows to change the full HTML code that is outputted to comments.
  • Filter: wpbcr_up_icons
    • Parameters:
      • (array) $icons
    • Allows you to add your own icon-names for up-voting.
  • Filter: wpbcr_down_icons
    • Parameters:
      • (array) $icons
    • Allows you to add your own icon-names for down-voting.
  • Filter: wpbcr_custom_css
    • Parameters:
      • (string) $css
    • Allows to add/change the custom CSS that is outputted on the frontend side
  • wpbcr_user_ip_addr_hashed
    • Parameters:
      • (string) $hashed_ip
    • Allows to change the hashed IP-Address of a user. Only triggered if hashing and IP-Logging is ON
  • wpbcr_user_ip_addr
    • Parameters:
      • (string) $ip
    • Allows to change the IP-Address of a user. Only triggered if hashing is OFF and IP-Logging is ON.

Since version 1.1:

  • Action: wpbcr_shortcode_best_comments_sql_sort_by
    • Parameters:
      • (array) &$sort_by (Passed as reference)
      • (string) $do
    • Allows to manipulate the $sort_by array
  • Filter: wpbcr_shortcode_best_comments_sql
    • Parameters:
      • (string) $sql The whole generated SQL query
      • (string) $where The SQL WHERE clause.
      • (string) $sort_by The SQL SORT BY clause.
      • (int) $limit The number to limit entries.
      • (string) $post_id The current post ID the shortcode is in. (Since 1.2).
      • (string) $do The to-do from the shortcode. (Since 1.2, default is ‘best_rated’).
    • Allows to manipulate the SQL query. See FAQ question 8 for more information on this.
  • Filter: wpbcr_shortcode_best_comments_li
    • Parameters:
      • (string) $li
      • (bool) $get_best_comments_of_blog
    • Allows to manipulate the whole <li> Element.
      • As per default and when $get_best_comments_of_blog is false the string is <li><a href="%2$s">%1$s</a> <span></span> (%4$d/%5$d)</li>
      • As per default an when $get_best_comments_of_blog is true the string is <li>%1$s on <a href="%2$s">%3$s</a> <span></span> (%4$d/%5$d)</li>
      • %1$s will be replaced with the name of the author
      • %2$s will be replaced with the URL to the comment
      • %3$s will be replaced with the title of the post the comment was written on
      • %4$d will be replaced with the rating
      • %5$d will be replaced with the total rating count
  • Filter: wpbcr_shortcode_best_comments_html_type
    • Parameters
      • $html_type (As per default this is ‘ol’)
    • Allows to change the HTML-Type of the surrounding li-Elements

Does it work with bbpress / buddypress?

No, it does not. The thing is that these plugins are using their own comment-system. They are not using internal WordPress comment functions.

Does it work with WooCommerce Review system?

Yes, because WooCommerce is using standard WordPress comments to produce reviews. However it’s up to the theme it will work for you. Unfortunately it’s not possible for me to test every single theme out there. So please ask before you buy.

I’ve tested the compatibility with the free Wootique theme. Here is the screenshot:

WP Comment Rating on WooCommerce
WP Comment Rating on WooCommerce

What are the shortcodes?

Since version 1.1 there is a shortcode that you can use:

  • Parameters:
    • post_id (Standard: ”)
      The post ID of the outputted comments. If empty, the current post ID is used. If ‘null’, the shortcode will return the most popular comments of all comments of the blog.
    • do (Standard: ‘best-rated’)
      Possible values: best-rated, highest-rating-count-and-best-rated, best-rated-and-highest-rating-count, highest-rating-count, lowest-rating-count, worst-rated, highest-rating-count-and-best-rated
    • limit (Standard: 5)
      The number of comments you want to show.

Used like this:

Can I display an icon when a comments get more than X up-votes?

Yes. For this use the ‘wpbcr_output_elements’ filter. You it to your themes functions.php or just by writing your own plugin like this (Download from Github).

How can I use the ‘wpbcr_shortcode_best_comments_sql’ filter?

Well, this isn’t really easy as you have to know how to handle SQL queries. Especially because the original query is already very complex.

Please take a look at the following Gist (code example). You can find additional hints right in the comments section there.

Is this compatible with XX plugin or XX theme?

The answer is: I don’t know! There are thousand different plugins and themes out there. For me it’s not possible to check everything. The best tip is: ask before you buy! Maybe I can test some things before you actually buy something. Assuming that my plugins is compatible with everything is not a good idea ;-)

Some things that have been tested already:

Compatible with … ?

  • Buddypress? – No!
  • BBPress – No!

Can I show the shortcode in the format like all other comments are shown?

Yes but that isn’t a feature of the plugin and it has some limitations, too. First of all: you have to write your own plugin. But you can access the Comment Ratings functionalities for this. Please take a look at this public gist to learn more about it. Please note the comment section, too!

Is there an option to only have up votes?

The best solution is to just go to the settings page of the plugin and deactivate the down-rating (use the on/off button). That’s it.

If you just want to hide it, you can also use a custom CSS for that in the Custom CSS box:

Can I show the rating for particular post types only?

Yes. This is possible since version 1.4.0. Just to your WordPress Administration panel -> “Comments” -> “Rating” -> “Settings” and scroll down to “Post Types”. Then select the post types you want to see the rating.

The comments are sorted the other way round, what can I do?

Go to your WordPress Administration panel -> “Settings” -> “Discussion” -> in “Other comment settings” change the dropdown in “Comments should be displayed with the …” from “older” to “newer” OR the other way round. The plugin has it’s own sorting method. You can swap the sorting here.

How can I show the number of up- and down votes?

Displays something like this:

Up- and Downvoting
Show separate up- and down votes.

You can write your own plugin that extends the WP Comment Rating plugin like this:

Copy the above code in a file and name it wp-comment-rating-extend.php. Move it into the wp-content/plugins/ folder and activate it from the plugins menu.

Can I get the rating when I use wp_list_comments() with a custom callback?

Yes. For this try to call the get_comment() function before outputting anything. This will apply all filters to the comment and therefore will output the rating, too. Here is an example:

In your comments.php template file:

In your themes functions.php:

Can I place to comment rating on a different place in my comments template?

Since version 1.5 this is possible. Follow the instructions below:

1. Remove the output of the elements by adding the following line anywhere in your themes functions.php:

This will remove the HTML code that produces the rating.

2. In your custom comment callback function you could use the following code:

This will display the rating again on the place that you have selected.