Rate my Post Plugin Documentation

Rate my Post - A free WordPress Rating plugin
Rate my Post - A free WordPress Rating plugin

Rate my Post is a free WordPress rating plugin. It allows visitors to rate your posts and can be downloaded from the official WordPress plugin directory.

Table of Contents:


Installation

From the Dashboard (Recommended):

  1. Navigate to Dashboard ▸ Plugins ▸ Add New
  2. Search for Rate my Post
  3. Click Install
  4. Click Activate

Manual Installation: 

  1. Download the plugin as a .zip file;
  2. Unzip downloaded archive and upload rate-my-post folder under your /wp-content/plugins/ directory
  3. Navigate to Dashboard ▸ Plugins
  4. Click Activate

Getting started

After the installation you can add the rating widget to your posts with the shortcode [ratemypost] or automatically in the plugin’s settings. The “rating widget” allows visitors to rate your posts (star rating). The plugin also comes with the results widget. The results widget shows the rating, but is not interactive (it doesn’t accept votes). On most websites you will find such a widget at the top of the post, before the title. You can add the results widget with the shortcode [ratemypost-result] or automatically in the plugin’s settings.


Options

The Rate my Post plugin is probably the most customizable and adjustable WordPress rating plugin. It comes with many options which allow you to completely customize the plugin so that it fits your website.

Settings

Rate my Post: The settings section
Rate my Post: The settings section

Below is a brief description of settings that might be a bit confusing to beginners.

Enable rich snippets

The plugin adds structured data to your website, and if your website is trustworthy and high-quality, the search engines might show rich snippets on results pages. If you enable this options you should also select the “Type of structured data for rich snippets” in the settings. The Rate my Post plugin supports the following types of structured data: Product, Book, Course, CreativeWorkSeason, CreativeWorkSeries, Episode, Game, LocalBusiness, MediaObject, Movie, MusicPlaylist, MusicRecording. Organization and Recipe. Other types can be implemented with the rmp_schema_type and rmp_structured_data filters. Note that since September, Google shows rich snippets only for a handful of structured data types. Read more about this here.

Color the stars in rating widget

This option colors the stars in the rating widget according to the average rating. If post is rated 3/5, three stars in the rating widget will be colored.

Disabled:

Rate my Post: The rating widget
Rate my Post: The rating widget

Enabled:

Rate my Post: The rating widget
Rate my Post: The rating widget

Enable half stars

If post is rated 3.7/5, four stars in rating widget will be colored (the rating is rounded). If you enable this option, 3.5 stars will be colored.

Disabled:

Rate my Post: The rating widget
Rate my Post: The rating widget

Enabled:

Rate my Post: The rating widget
Rate my Post: The rating widget

Show star hover texts

This is a handy feature to prevent accidental votes. When a user hovers over the stars, the descriptive rating is shown under the stars.

Disabled (hovering over two stars):

Rate my Post: The rating widget
Rate my Post: The rating widget

Enabled (hovering over two stars):

Rate my Post: The rating widget
Rate my Post: The rating widget

Prevent accidental votes

This feature is for mobile/touch devices. When a visitor clicks on a star, he/she needs to confirm the vote by clicking the “Rate” button that pops up under the widget. It prevents the visitors from accidentally casting votes.

Rate my Post: Prevent accidental votes
Rate my Post: Prevent accidental votes

Google Analytics event tracking

This feature allows you to track votes in Google Analytics. At the moment, it’s only compatible with the following Google Analytics plugins: GA Google Analytics, MonsterInsights and Google Analytics by ShareThis.

Delete cookie on page load

After the page is refreshed the cookie is deleted. This feature comes in handy while you are setting up the plugin, and might want to cast multiple votes to see how the plugin performs.

Exclude rating and result widget from

If you automatically add the rating/results widget to your posts or pages in the options, you might want to remove it from specific posts/pages, for example the about us page. Here you should insert Insert comma separated post/page IDs. To get the post ID, visit posts/pages menu in your admin dashboard and click on the page/post that you need an ID for. Then check the URL and you should see something like “www.example.com/wp-admin/post.php?post=61&action=edit”. The ID is the number in the URL. In this case it is 61.

Feedback Widget

It can be enabled in the settings. The Feedback Widget allows visitors to send you private feedback after they rated a post on your website. The idea behind the feedback widget is that you can improve your posts. It will be shown if the post gets a negative rating. You define what is a negative rating in the settings; “If post or page is rated X/5 stars or less, consider the rating negative.”.

Rate my Post: The feedback widget
Rate my Post: The feedback widget

Social Widget

It can be enabled in the options. The Social Widget shows social follow or social share icons/links after the post has been rated positively. You define what is a positive rating in the options. You can also chose whether to show social follow buttons or social share buttons.

Rate my Post: The social widget
Rate my Post: The social widget

Count negative ratings only if feedback is left

With this feature, the negative ratings will be counted only if the feedback is left. It’s another handy feature to prevent accidental votes.

Show ratings on archive pages

This feature will show ratings with stars on archive pages (list of posts) next to the title. It will also show ratings on the main blog page.

Remove headings in rating widget

This is a handy feature if you use some kind of Table of Contents plugin. It replaces headings with paragraphs in all widgets.

Multilingual website compatibility mode

If your website is available in more than one language, you should enable this feature. After enabling this feature, you won’t be able to modify strings in the Customize section. You should instead modify strings with a translations plugin such as Loco Translate.

Customize

Rate my Post: The customize section
Rate my Post: The customize section

In the customize section you can change colors, sizes and modify strings. All settings here are pretty straightforward.

Security Options

Rate my Post: The security section
Rate my Post: The security section

Ratings manipulation requires role of

Rate my Post enables you to change ratings in the backend in the post editor (metabox at the bottom). Here you can set which role is required to manipulate ratings. Available options are: Admin, Author and Editor.

Rate my Post: Ratings can be changed in the backend
Rate my Post: Ratings can be changed in the backend

Who can rate posts

Here you can select who can rate posts. By default all visitors can rate posts. Nevertheless, you can limit rating capability to only logged-in users.

Track IP addresses

If this feature is enabled, IP addresses of voters will be tracked and available in the Analytics section. This feature must be enabled if you want to prevent double votes via IP address. If this feature is enabled, GDPR compliance is voided.

Track users

If this feature is enabled, you will see the nicknames of logged-in users who rated your posts in the analytics section.

Google reCAPTCHA v3

Google reCAPTCHA v3 verifies if an interaction is legitimate without any user interaction. You will need the reCAPTCHA v3 site key and the secret key to use this option. The service is free of charge. You can get the keys here: reCAPTCHA v3.

Migration Tools

Rate my Post: The migration section
Rate my Post: The migration section

The migration tools allow you to migrate votes and ratings from kk Star Ratings, YASR and WP-PostRatings with one click. The tools are available if one of the mentioned plugins is installed on your website.


Filters

Filters provide a way for functions to modify data of Rate my Post functions.

Modifying strings for custom post types, specific categories etc.

rmp_custom_strings

The rmp_custom_strings filter allows you to change strings in various scenarios. For example, if you have a book custom post type, you probably want different texts in the book posts. The strings for the book posts can be easily modified as shown in the example below.

/*FILTER EXAMPLE
The array has the following keys:
rateTitle, 
rateSubtitle, 
rateResult, 
rateResult2, 
cookieNotice, 
noRating, 
afterVote, 
star1, 
star2,
star3,
star4,
star5,
socialTitle,
socialSubtitle,
feedbackTitle,
feedbackSubtitle,
feedbackText,
feedbackNotice,
feedbackButton,
feedbackAlert,
submitButtonText
*/

function blazzdev_modify_rmp_strings( $stringsArray ) {
  if ( is_singular( 'book' ) ) { //modify only for Book custom post type
    $stringsArray['rateTitle'] = 'Did you like this book?';
    $stringsArray['rateSubtitle'] = 'Click on a star to rate this book!';
    $stringsArray['afterVote'] = 'Thank you for rating this book';
    $stringsArray['socialTitle'] = 'As you found this book useful...';
    $stringsArray['feedbackTitle'] = 'How come you did not like this book?';
    $stringsArray['feedbackSubtitle'] = 'How could this book be improved?';
    $stringsArray['feedbackText'] = 'Give us some tips...';
  }
  return $stringsArray;
}

add_filter( 'rmp_custom_strings', 'blazzdev_modify_rmp_strings' );

Code goes to your child theme’s functions.php.

Removing specific social share icons

rmp_social_links

If you enable the social widget and the “use social share icons instead of social follow icons” in the settings, the plugin will by default print all available social share icons. However, you can remove specific social share icons with the filter as shown below. The snippet below will remove the Twitter and the Reddit social share icon.

function blazzdev_remove_social_icons( $socialLinks ) {
  unset( $socialLinks['twitter'] );
  unset( $socialLinks['reddit'] );
  return $socialLinks;
}
add_filter( 'rmp_social_links', 'blazzdev_remove_social_icons' );

Code goes to your child theme’s functions.php.

Remove ratings from specific archive pages or home page

rmp_archive_results

If you enable the “show ratings on archive pages” feature in the settings, the plugin will by default show ratings on all archive pages and the main blog page. With this filter you can remove ratings from specific archives or the main blog page.

Example 1:

The code below will remove ratings from author archives.

function blazzdev_exclude_author( $content ) {
  if ( is_author() ) {
    return false;
  } else {
    return $content;
  }
}
add_filter( 'rmp_archive_results', 'blazzdev_exclude_author' );

Code goes to your child theme’s functions.php.

Example 2: 

The snippet below will remove ratings from the main blog page.

function blazzdev_exclude_home( $content ) {
  if ( is_home() ) {
    return false;
  } else {
    return $content;
  }
}
add_filter( 'rmp_archive_results', 'blazzdev_exclude_home' );

Code goes to your child theme’s functions.php.

Replacing the default icons (stars etc.) with custom icons

rmp_rating_icon_class

This filter enables you to add a custom class to the icon or simply replace the default class with the custom class. Therefore, you can use your own icons (via background-image property) or whichever icon from FontAwesome (if you use FontAwesome on your website). Since version 2.10.0 the plugin no longer loads FontAwesome library as it uses a custom and lighter font. The code below will replace the stars with the FontAwesome car icons.

function blazzdev_custom_class( $class ) {
  return 'fa fa-car';
}

add_filter( 'rmp_rating_icon_class', 'blazzdev_custom_class' );

Code goes to your child theme’s functions.php.

Changing the schema type

rmp_schema_type

This filter enables you to change the schema type.

Example 1 – Change the schema type for a custom type:

Let’s say that you have a custom post type of recipe and of course you want the recipe schema in all recipe posts. Nevertheless, elsewhere you want the schema type selected in the options.

function blazzdev_schema( $schemaType ) {
  if( is_singular( 'recipe' ) ) {
    return 'Recipe';
  }
  return $schemaType;
}

add_filter( 'rmp_schema_type', 'blazzdev_schema' );

Code goes to your child theme’s functions.php.

Example 2 – Choose the schema type for each post in the post editor:

In the example below we utilize this filter to build our own system through which we can choose the schema type for each post in the post editor. First we put the snippet below into functions.php.

function blazzdev_dynamic_schema( $schemaType ) {
  $schema = get_post_meta( get_the_id(), 'my_schema_type', true );
  if( $schema ) { //else use the schema from the options 
    return $schema;
  }

  return $schemaType;
}

add_filter( 'rmp_schema_type', 'blazzdev_dynamic_schema' );

Code goes to your child theme’s functions.php.

When the snippet above is added, you specify the schema type in the post editor through a custom field.  Read the guide on how to create a custom field here. The custom field’s name should be my_schema_type and the value should be one of the following: Product, Book, Course, CreativeWorkSeason, CreativeWorkSeries, Episode, Game, LocalBusiness, MediaObject, Movie, MusicPlaylist, MusicRecording, Organization or Recipe. See the image below. If the custom field doesn’t exist the schema type specified in the settings will be used.

Rate my Post - Choose schema type in post editor
Rate my Post - Choose schema type in post editor

Changing the structured data

rmp_structured_data

This filter enables you to modify the complete structured data.

Example 1 – Change schema type to Event 

function blazzdev_event_structured_data( $structuredData ) {
  $voteCount = rmp_get_vote_count();
  $rating = rmp_get_avg_rating();
  $img = get_the_post_thumbnail_url();
  $name = get_the_title();
  $locationType = get_post_meta( get_the_id(), 'myschema_locationType', true );
  $locationName = get_post_meta( get_the_id(), 'myschema_locationName', true );
  $locationAddress = get_post_meta( get_the_id(), 'myschema_locationAddress', true );
  $startDate = get_post_meta( get_the_id(), 'myschema_startDate', true );
  $endDate = get_post_meta( get_the_id(), 'myschema_endDate', true );
  $performer = get_post_meta( get_the_id(), 'myschema_performer', true );

  $structuredData = '
  <script type="application/ld+json">
    {
    "@context": "http://schema.org",
    "@type": "Event",
    "aggregateRating": {
      "@type": "AggregateRating",
      "bestRating": "5",
      "ratingCount": "' . $voteCount . '",
      "ratingValue": "' . $rating . '"
    },
    "image": "' . $img . '",
    "name": "' . $name . '",
    "location": {
      "@type": "' . $locationType . '",
      "name": "' . $locationName . '",
      "address": "' . $locationAddress . '"
    },
    "startDate": "' . $startDate . '",
    "endDate": "' . $endDate . '",
    "description": "' . $name . '",
    "performer": "' . $performer . '"
    }
  </script>
  ';

  return $structuredData;
}

add_filter( 'rmp_structured_data', 'blazzdev_event_structured_data' );

Code goes to your child theme’s functions.php.

When the snippet above is added, you specify the details for this schema type in the post editor through custom fields. See the image below.

Event Schema Type
Event Schema Type for Rate my Post

Example 2 – Change schema type to SoftwareApplication 

function blazzdev_sa_structured_data( $structuredData ) {
  $voteCount = rmp_get_vote_count();
  $rating = rmp_get_avg_rating();
  $img = get_the_post_thumbnail_url();
  $name = get_the_title();
  $operatingSystem = get_post_meta( get_the_id(), 'myschema_operatingSystem', true );
  $applicationCategory = get_post_meta( get_the_id(), 'myschema_applicationCategory', true );

  $structuredData = '
  <script type="application/ld+json">
    {
    "@context": "http://schema.org",
    "@type": "SoftwareApplication",
    "aggregateRating": {
      "@type": "AggregateRating",
      "bestRating": "5",
      "ratingCount": "' . $voteCount . '",
      "ratingValue": "' . $rating . '"
    },
    "image": "' . $img . '",
    "name": "' . $name . '",
    "description": "' . $name . '",
    "applicationCategory": "' . $applicationCategory . '",
    "operatingSystem": "' . $operatingSystem . '"
    }
  </script>
  ';

  return $structuredData;
}

add_filter( 'rmp_structured_data', 'blazzdev_sa_structured_data' );

Code goes to your child theme’s functions.php.

When the snippet above is added, you specify the details for this schema type in the post editor through custom fields. See the image below.

SoftwareApplication Schema Type for Rate my Post
SoftwareApplication Schema Type for Rate my Post

Remove IP double vote protection for posts, custom post types etc.

rmp_double_vote

This filter enables you to remove IP double vote protection if specified conditions are met. In the example below we remove IP double vote protection for the post with the ID of 246.

function blazzdev_remove_ip_double_vote( $doubleVotes, $postID ) {
  if ( $postID == 246 ) {
    //return an empty array - meaning no matches for the ip
    $doubleVotes = array();
  }
  return $doubleVotes;
}

add_filter( 'rmp_double_vote', 'blazzdev_remove_ip_double_vote', 10, 2 );

Code goes to your child theme’s functions.php.

Merge ratings during the migration

rmp_migrate_merge

This filter enables you to merge the ratings of Rate my Post plugin and another plugin during the migration. Rate my Post supports migration from the following plugins: kk Star Ratings, YASR and WP-PostRatings.

function blazzdev_merge_during_migration( $merge ) {
  return true;
}

add_filter( 'rmp_migrate_merge', 'blazzdev_merge_during_migration' );

Code goes to your child theme’s functions.php.

Change email address

rmp_mail_address

Rate my Post plugin by default sends emails about new votes and feedback to the admin email. You can change the email with this filter.

add_filter( 'rmp_mail_address', 'blazzdev_change_rmp_email' );

function blazzdev_change_rmp_email( $email ) {
  return '[email protected]';
}

Code goes to your child theme’s functions.php.

Change subject for “post rated” emails

rmp_mail_subject

You can modify the subject of the “post rated” email with this filter.

add_filter( 'rmp_mail_subject', 'blazzdev_rate_mail_custom_title', 10, 7 );

function blazzdev_rate_mail_custom_title( $subject, $postID, $rating, $newAvgRating, $newVoteCount, $postTitle, $postLink ) {
  return $postTitle. ' rated ' . $rating . ' and now has ' . $newVoteCount . ' votes and rating of ' . $newAvgRating;
}

Code goes to your child theme’s functions.php.

Change text for “post rated” emails

rmp_mail_text

You can modify the text (content) of the “post rated” email with this filter.

add_filter( 'rmp_mail_text', 'blazzdev_rate_mail_custom_text', 10, 7 );

function blazzdev_rate_mail_custom_text( $message, $postID, $rating, $newAvgRating, $newVoteCount, $postTitle, $postLink ) {
  return 'Post rated ' . $rating . '. Post name ' . $postTitle;
}

Code goes to your child theme’s functions.php.

Change subject for “feedback” emails

rmp_feedback_mail_subject

You can modify the subject of the “feedback” email with this filter.

add_filter( 'rmp_feedback_mail_subject', 'blazzdev_feedback_mail_custom_subject', 10, 4 );

function blazzdev_feedback_mail_custom_subject( $message, $postID, $feedback, $postTitle ) {
  return $postTitle . ' has a new feedback!';
}

Code goes to your child theme’s functions.php.

Change text for “feedback” emails

rmp_feedback_mail_text

You can modify the text (content) of the “feedback” email with this filter.

add_filter( 'rmp_feedback_mail_text', 'blazzdev_feedback_mail_custom_text', 10, 4 );

function blazzdev_feedback_mail_custom_text( $message, $postID, $feedback, $postTitle ) {
  return 'Comment from a visitor: ' . $feedback . ' Post: ' . $postTitle;
}

Code goes to your child theme’s functions.php.

Prevent accidental votes only on mobile

rmp_prevent_accidental

If prevent accidental votes is enabled, a visitor has to confirm the vote by clicking the submit button. It is possible to apply this feature only to mobile devices where accidental votes are the most common.

add_filter( 'rmp_prevent_accidental', 'blazzdev_exclude_desktop', 10, 4 );

function blazzdev_exclude_desktop( $preventAccidentalAll ) {
  return 1;
}

Code goes to your child theme’s functions.php.


Actions

Actions provide a way for running a function at a specific point in the execution of the plugin.

Printing custom content beneath all widgets (at the bottom)

rmp_after_all_widgets

This action enables you to print custom content beneath the rating widget. For example if you allow only registered users to vote, you probably want to notify them that they need to register in order to vote. See the example below:

function blazzdev_add_after_rating_widgets() {
  if ( !is_user_logged_in() ) {
    echo '<p>Please login to rate!</p>';
  }
}
add_action( 'rmp_after_all_widgets', 'blazzdev_add_after_rating_widgets');

Code goes to your child theme’s functions.php.

Printing custom content above all widgets (at the top)

rmp_before_all_widgets

This action allows you to print custom content above the rating widget. The example below will print “Please login to rate!” before the widget.

function blazzdev_add_before_rating_widgets() {
  if ( !is_user_logged_in() ) {
    echo 'Please login to rate!';
  }
}
add_action( 'rmp_before_all_widgets', 'blazzdev_add_before_rating_widgets');

Code goes to your child theme’s functions.php.

Printing custom content beneath the rating widget on AMP pages

rmp_after_widget_amp

This action enables you to print custom content beneath the AMP rating widget.

add_action( 'rmp_after_widget_amp', 'blazzdev_after_amp_rating_widget' );

function blazzdev_after_amp_rating_widget() {
  echo 'Hello world';
}

Code goes to your child theme’s functions.php.

Printing custom content above the rating widget on AMP pages

rmp_before_widget_amp

This action enables you to print custom content above the AMP rating widget.

add_action( 'rmp_before_widget_amp', 'blazzdev_before_amp_rating_widget' );

function blazzdev_before_amp_rating_widget() {
  echo 'Hello world';
}

Code goes to your child theme’s functions.php.

Printing custom content above the social icons (social widget)

rmp_before_social_icons

This hook enables you to print custom content above the social icons in social widget. Note that social widget has to be enabled for this feature to work. In the example below we add the subscribe to the newsletter CTA before the social share icons.

function blazzdev_before_social_icon() {
  echo '<p><a href="https://example.com/subscribe">Subscribe to our newsletter!</a></p>';
}
add_action( 'rmp_before_social_icons', 'blazzdev_before_social_icon');

Code goes to your child theme’s functions.php.

Printing custom content beneath the social icons (social widget)

rmp_after_social_icons

This hook enables you to print custom content after the social icons in social widget. For instance, it can be used to add an additional social network/social share icon. In the example below we add the Tumblr icon with the link to our Tumblr page. The social widget has to be enabled for this feature to work.

function blazzdev_after_social_icon() {
  echo '<a target="_blank" href="https://www.tumblr.com/mysite" rel="noopener noreferrer"><i class="fa fa-tumblr"></i></a>';
}
add_action( 'rmp_after_social_icons', 'blazzdev_after_social_icon');

Code goes to your child theme’s functions.php.

Printing custom content beneath the social widget

rmp_after_social_widget

This hook enables you to print custom content beneath the social widget itself. In the example below we add a subscribe link beneath the widget.

function blazzdev_after_social_widget() {
  echo '<p>or subscribe to our newsletter <a href="https://example.com/subscribe">here</a>!</p>';
}
add_action( 'rmp_after_social_widget', 'blazzdev_after_social_widget');

Code goes to your child theme’s functions.php.

Printing custom content above the feedback widget

rmp_before_feedback_form

This hook allows you to print custom content above the feedback form. Note that the feedback widget has to be enabled for this feature to work. In the example below we add a contact us link above the feedback form.

function blazzdev_before_feedback() {
  echo '<p>We\'d love to hear why you didn\'t like this post. Contact us <a href="https://example.com/about">here</a>!</p>';
}
add_action( 'rmp_before_feedback_form', 'blazzdev_before_feedback');

Code goes to your child theme’s functions.php.

Printing custom content beneath the feedback widget

rmp_after_feedback_form

This hook allows you to print custom content beneath the feedback form. Note that the feedback widget has to be enabled for this feature to work. In the example below we add a link to the “about us” page beneath the feedback form.

function blazzdev_after_feedback() {
  echo '<p>or learn more about us <a href="https://example.com/about">here</a>!</p>';
}
add_action( 'rmp_after_feedback_form', 'blazzdev_after_feedback');

Code goes to your child theme’s functions.php.

Adding additional information to the Top Rated Posts widget

rmp_before_widget_title

The top rated posts widget shows the top rated posts with the following information: featured image, visual rating and the title. If you want to add additional information such as author name, published date, modified date etc. you can do so with this filter. The example below shows how to add the published date.

function blazzdev_trpw_published_date( $postID ) {
  $date = get_the_date( '', $postID );
  echo '<p>Published: '. $date . '</p>';
}
add_action( 'rmp_before_widget_title', 'blazzdev_trpw_published_date' );

Code goes to your child theme’s functions.php.


Global Functions/Methods

The Rate my Post WordPress plugin allows you to build custom solutions on top of it. With the global functions you can easily get information such as vote count, average rating etc. for use globally on your website.

Get the average rating

rmp_get_avg_rating( $postID )

This function returns the average rating for the specified post. If $postID is not provided, it returns average rating for the current post. In case of no ratings the function returns false.

rmp_get_avg_rating( $postID )

Get the vote count

rmp_get_vote_count( $postID )

This function returns the vote count for the specified post. If the $postID is not provided, it returns the vote count for the current post. In case of no ratings the function returns false.

rmp_get_vote_count( $postID )

Get the visual rating

Rate_My_Post_Public_Helper::get_visual_rating()

This method returns the visual rating (stars or whichever icon you chose in the options) for the specified post. If the $postID is not provided, it returns the visual rating for the current post. Note that the stars are without style and thus you need to style them yourself.

Rate_My_Post_Public_Helper::get_visual_rating();

Get the top rated posts

Rate_My_Post_Public_Helper::top_rated_posts( 3, 4.5 );

This method returns an array of top rated posts with titles, urls, featured images, average ratings and vote counts. It accepts two arguments: number of posts and the required minimum average rating. With this method you can build your own top rated posts widget.

Rate_My_Post_Public_Helper::top_rated_posts( 3, 4.5 );

CSS Snippets

The style can be further adjusted with custom CSS. Below are some CSS snippets which you can use.

Hide the plugin for users who are not logged in

If “Only logged in users can vote” feature is enabled, you can hide the plugin for users who are not logged in. See example below.

.rmp-not-logged-in {
    display: none;
}

Code goes to your child theme’s style.css.

Hide the rating widget if user already rated the post

With the snippet below the rating widget won’t show if the user already rated the post.

.rmp-rated {
    display: none;
}

Code goes to your child theme’s style.css.

Style the submit feedback button

The submit feedback button (for mobile/touch devices) can’t be styled in the customize section, but you can easily style it with custom CSS.

button#feedback-button {
    height: 70px;
    padding: 10px;
    width: 250px;
    margin: 1em auto;
    background-color: #FEB1C0;
    border: none;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5em;
}

button#feedback-button:hover {
    cursor: pointer;
    background-color: blue;
}

Code goes to your child theme’s style.css.

Hide the Google ReCaptcha badge (only if ReCaptcha is enabled)

Note that you must include link to the terms of use and the privacy policy according to the reCAPTCHA v3 Terms of Use.

.grecaptcha-badge {
  display: none;
}

Code goes to your child theme’s style.css.

Change the color of empty stars in rating widget

With the snippet below we are changing the color of empty stars in rating widget to #e6e6ff.

.rating-stars ul > li.star > i.fa {
    font-size: 2.5em;
    color: #e6e6ff; /* Stars color */
    cursor: pointer;
}

.half-icon-highlight i {
    background: linear-gradient(to right, #ffe699 50%,#e6e6ff 50%); /* Insert both, stars color and stars highlight color */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

Code goes to your child theme’s style.css.

Change the color of empty stars in results widget

With the snippet below we are changing the color of empty stars in results widget to green.

.rmp-results .star-result .fa {
    color: green;
}

.rmp-results .star-result .fa.star-half-highlight {
    background: linear-gradient(to right, #FF912C 50%,green 50%); /* Insert both, stars color and results color */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

Code goes to your child theme’s style.css.

Change text area width in feedback widget

With the snippet below we are making the text area in feedback widget take 100% of the page width.

.rmp-text-area {
    min-width: 100%; /* Width of text area */
}

Code goes to your child theme’s style.css.

 


Troubleshooting

While Rate my Post plugin works with most themes and plugins, it’s impossible to ensure 100% compatibility, not least because many WordPress websites use custom solutions. Below are the most common fixes.

The “Add rating widget to all posts” feature is not working

In case that that the rating widget is not inserted automatically I recommend using shortcodes instead. If this sounds like too much work you can always include the widget directly in the template with the following snippet:

<?php echo do_shortcode('[ratemypost]'); ?>

The best place to add this snippet is under the while loop in the single.php file of your theme (/wp-content/themes/yourtheme/single.php).

Rate my Post - Add rating widget to the template
Rate my Post - Add rating widget to the template

Dots are shown before the stars

If dots are shown before the stars in the rating widget, this snippet typically helps.

ul#rmp-stars li:before {
    content: '';
}

Code goes to your child theme’s style.css.

Stars are shown vertically

If stars are shown vertically, this snippet typically helps.

.rating-stars ul > li.star {
    display: inline-block !important;
    width: auto;
}

Code goes to your child theme’s style.css.


AMP Compatibility (BETA)

Since version 2.3.0 the plugin is AMP-compatible. This is a BETA feature, so let me know if you spot bugs. Currently AMP and AMP for WP plugins are supported. It will not work with other plugins.

To add rating/result widgets to your AMP pages first enable AMP compatibility mode in advanced settings. The AMP widgets are without any style and therefore you need to apply style yourself – the style that works well in most cases is below.

/* Rate my Post CSS for AMP with the help of AMP by Example - https://ampbyexample.com/advanced/star_rating/ */

  /* Results widget stars */
  .rmp-amp-star::before {
    content: "★";
    font-size: 26px;
    color: #ccc;
    margin: -2px;
  }

  .rmp-amp-star-highlighted::before {
    color: #FF912C;
  }

  .rmp-amp-stars, .rmp-amp-average, .rmp-amp-votes {
    display: inline-block;
  }

  /* Text-align center in rating widget */
  .rmp-amp-rating-widget {
    text-align: center;
  }

  /* Bottom margin on title */
  #rmp-amp-rating-widget-title {
    margin-bottom: 10px;
  }

  /* These two inputs should not be displayed */
  #rmp-amp-action, #rmp-amp-post-id {
    display: none;
  }

  /* Center the stars */
  .rmp-amp-centered-fieldset {
    margin-left: auto;
    margin-right: auto;
    max-width: 200px;
  }

  .rmp-amp-rating {
    --star-size: 3;  /* use CSS variables to calculate dependent dimensions later */
    padding: 0;  /* to prevent flicker when mousing over padding */
    border: none;  /* to prevent flicker when mousing over border */
    unicode-bidi: bidi-override; direction: rtl;  /* for CSS-only style change on hover */
    text-align: left;  /* revert the RTL direction */
    user-select: none;  /* disable mouse/touch selection */
    font-size: 3em;  /* fallback - IE doesn't support CSS variables */
    font-size: calc(var(--star-size) * 1em);  /* because <code>var(--star-size)em</code> would be too good to be true */
    cursor: pointer;
    /* disable touch feedback on cursor: pointer - http://stackoverflow.com/q/25704650/1269037 */
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    -webkit-tap-highlight-color: transparent;
    margin-bottom: 16px;
  }
  /* the stars */
  .rmp-amp-rating > label {
    display: inline-block;
    position: relative;
    width: 1.1em;  /* magic number to overlap the radio buttons on top of the stars */
    width: calc(var(--star-size) / 3 * 1.1em);
  }
  .rmp-amp-rating > *:hover,
  .rmp-amp-rating > *:hover ~ label,
  .rmp-amp-rating:not(:hover) > input:checked ~ label {
    color: transparent;  /* reveal the contour/white star from the HTML markup */
    cursor: inherit;  /* avoid a cursor transition from arrow/pointer to text selection */
  }
  .rmp-amp-rating > *:hover:before,
  .rmp-amp-rating > *:hover ~ label:before,
  .rmp-amp-rating:not(:hover) > input:checked ~ label:before {
    content: "★";
    position: absolute;
    left: 0;
    color: gold;
  }
  .rmp-amp-rating > input {
    position: relative;
    transform: scale(3);  /* make the radio buttons big; they don't inherit font-size */
    transform: scale(var(--star-size));
    /* the magic numbers below correlate with the font-size */
    top: -0.5em;  /* margin-top doesn't work */
    top: calc(var(--star-size) / 6 * -1em);
    margin-left: -2.5em;  /* overlap the radio buttons exactly under the stars */
    margin-left: calc(var(--star-size) / 6 * -5em);
    z-index: 2;  /* bring the button above the stars so it captures touches/clicks */
    opacity: 0;  /* comment to see where the radio buttons are */
    font-size: initial; /* reset to default */
  }
  form.amp-form-submit-error [submit-error] {
    color: red;
  }

The process of applying the style is AMP plugin specific.

AMP plugin

Paired Mode: you simply add the style in the Appearance -> Customize -> Custom CSS section.

Classic Mode: You need to utilize the amp_post_template_css filter in your child theme’s functions.php or a custom-made plugin:

add_action( 'amp_post_template_css', 'xyz_amp_my_additional_css_styles' );

function xyz_amp_my_additional_css_styles( $amp_template ) {
  // only CSS here please...
  ?>
  /* Above listed style goes here */
  <?php
}

AMP for WP plugin

If you are using AMP for WP plugin, you will first have to disable form sanitization as the plugin automatically strips forms out of the document. A tutorial how to do this is available here.

After form sanitization is disabled you just copy/paste the style to Design -> Style in the AMP for WP plugin’s settings.

 


Blaz K.

I am a web developer with experience building WordPress websites, plugins and themes. I specialize in PHP and have professional experience working with JavaScript, CSS, PostCSS, Gulp and HTML. I also have experience working with PrestaShop, GIT and SEO.


Leave a Reply

Your email address will not be published. Required fields are marked *

8 comments on “Rate my Post Plugin Documentation

Hi sir thank you for your plugin, it is nice
I wish to ask you how to get users` rating for one post , with their comment,

in analytics section I can find user`s rating, so how to display it as result star in comments of single post

Reply

Hi there,

I’m not sure I completely understand your question. Feedback is private and visible only to logged in users (admins, editors, authors etc.).

Regards,
Blaz

Reply

Hello, Thanks for the damn good plugin. I still have a question. How can I integrate the result between the metadata? Which PHP value…

***) ***

…is required for this? Thank you very much, best Regards, Rene from Berlin GERMANY

Reply

Hi Rene,

where exactly would you like the result to show? 🙂

There is a global function which returns the average rating: rmp_get_avg_rating( $postID )

Regards,
Blaz

Reply

Hello! Thanks for the plugin.
Is there any way to have only the rating stars (not the result but the stars used to vote)?
I mean, only the stars without all structure around?
We could use a lot “display:none” on the paragraph before and after but it’s not the proper way.
Any idea? 🙂
Thank you!

Reply

Hi Gilbert,

that’s an option, but you can also just leave the fields empty in the customize section (title, subtitle). If you decide for this I recommend switching on “Remove headings in rating widget” in the advanced settings.

Regards,
Blaz

Reply

Hey Blaz, thanks a lot for the cool plugin!

A quick question though – during setup a lot of dummy data was generated for the pages on which the plugin shortcode was tested. How can we clear/purge this data besides going to MySQL?

Reply

Hi Andy,

I see two options:

1. You enable “Delete all plugin data on uninstall” in the advanced settings, delete the plugin and reinstall it. The problem here is that you will also loose all settings etc. :/

2. You first comment out or delete the following lines in unistall.php

delete_option(‘rmp_options’);
delete_option(‘rmp_customize_strings’);
delete_option(‘rmp_version’);
delete_option(‘rmp_security’);

and then you follow the first option 🙂 This way the settings will not be deleted but all other data will be. I haven’t tested this, so I recommend you backup the database before, just in case.

Regards,
Blaz

Reply