If you have custom code which relies on the Multi Rating Pro plugin and the plugin is disabled, a PHP fatal error will occur. It is best practice to first check the plugin is installed and activated before calling any API functions from a plugin. See class_exists() or function_exists() PHP functions.

Table of Contents

  1. Search Form
  2. Add ” ratings)” text to the end of the count
  3. Refresh Rating Item Results
  4. Increase font size of stars or thumbs
  5. Change the default schema.org microdata (rich snippets)
  6. Custom WP Query Sort
  7. Automatically approve ratings > 3 out of 5 stars
  8. Check if user rating exists
  9. Rearrange comment form fields

Search Form

The code snippet below allows the user to select an overall star rating as search criteria in the search form. The star ratings are rounded half up or half down e.g. an overall star rating of 4.67/5 will show up in search results for 5 stars.

Add ” ratings)” text to the end of the count

Changes the count of rating entries displayed alongside the rating results to be “(X ratings)” instead of “(X)”.

Refresh Rating Item Results

By default, when a rating is saved, updated or deleted, only the rating results for the specific post and rating form are recalculated. If you are using the the [mrp_rating_item_results] shortcode or the rating_item_ids shortcode attribute (e.g. [mrp_rating_result rating_item_ids="1,2"]), the associated rating results are recalculated on page load (not immediately when a rating is saved, updated or deleted).

Increase font size of stars or thumbs

Font Awesome is used for the star and thumbs icons. To increase the size of the star and thumb icons you can simply increase the font-size using some CSS.

Change the default schema.org microdata (rich snippets)

Multi Rating Pro by default uses the schema.org “http://schema.org/Article” when adding aggregateRating microdata or rich snippets to a post. The following code snippets uses the filter mrp_rating_result_microdata to replace this with your own schema.org microdata for “http://schema.org/Recipe”.

Custom WP Query Sort

Automatically approve ratings > 3 out of 5 stars

Check if user rating exists

Rearrange comment form fields

This code sample rearranges the comment form fields for anonymous users. It moves the comment, author, email and url fields to the end of the form. Therefore, any rating items, review fields or custom fields will be shown first in the comment form. Note the code sample relies on the comment_form_fields filter which is only available since WordPress 4.4.