Skip to main content
Agency Program Hosting from 10% off. A dedicated account manager. Priority support. Built for growing agencies. Hosting from 10% off, a dedicated account manager and priority support for growing agencies. Speak to the team Join free
WP-PostRatings icon

WP-PostRatings

v2.0.2
by Lester Chan · 4.4 (178 reviews)

Adds an AJAX rating system for your WordPress site's content.

20K+ active installs Updated Sep 01, 2026 Tested to 7.1.5 Requires PHP 8.2
Try Demo Download
Pre-installed Ready in ~10s No card
WP-PostRatings

About WP-PostRatings

This guide explains how to add ratings to your WordPress theme. You can add the ratings code to your theme files or use shortcodes to embed ratings into specific posts or pages. The plugin is available on GitHub and the developer accepts donations for their work.

Screenshots

WP-PostRatings screenshot
WP-PostRatings screenshot
WP-PostRatings screenshot
WP-PostRatings screenshot
WP-PostRatings screenshot
WP-PostRatings screenshot

Frequently asked questions

How do I add ratings to all posts or pages?
To add ratings to all posts or pages, locate the line <?php while (have_posts()) : the_post(); ?> in your theme's index.php, archive.php, single.php, post.php or page.php file. Then, add <?php if(function_exists('the_ratings')) { the_ratings(); } ?> anywhere below it where you want the ratings to appear.
How do I add ratings to a specific post or page?
To add ratings to a specific post or page, type [ratings] into the content of the selected post or page. This will embed ratings into that post or page only.
How can I display ratings from another post or page?
You can embed ratings from another post by using [ratings id="1"], where "1" is the ID of the post or page whose ratings you want to display. If you want to embed the results of other post ratings, use [ratings id="1" results="true"], where "1" is the ID of the post or page ratings results you wish to show.

Changelog

2.0.2

  • NEW: A wp_postratings_needs_assets filter, for code that renders a rating where WP-PostRatings cannot see it coming. 2.0.0 loads the stylesheet and the rating script only where it finds the ratings widget, a [ratings] shortcode, the block, or a rating rendering during the page itself. Rating markup fetched over admin-ajax.php or the REST API into a page that shows no rating of its own is none of those, and got neither file — leaving a rating that cannot vote and, since every shape is a CSS mask, draws as a bare row of radio buttons. Returning true from the filter is how such a page asks for them.

2.0.1

  • NEW: Numbers is a rating shape again. It was the one pre-2.0.0 image set with no shape to land on — every other set was a glyph repeated once per point, and a CSS mask cannot differ per position — so it was parked on circles, and a site that had chosen numbers came back from the update to five identical circles with no way to get the digits back. Numbers is now a shape of its own, offered under Scale beside the others, and the numbers image set maps onto it. It draws as one continuous bar of cells rather than five floating glyphs, and takes its colours from the Rated and Not rated settings like every other shape, so it has no palette of its own. Sites already migrated onto circles can simply select it; nothing about their ratings changes, only what those ratings are drawn with
  • NEW: wp_postratings_shapes accepts 'type' => 'numeric', for a scale drawn as its own positions. Such a shape needs no path, and the digits follow the site’s locale
  • FIXED: The shape picker grouped its rows by the shape’s exact type rather than by the control it is — a scale, or a pair of opposing actions. Any shape whose type was neither of the two words the radios offer landed in a group no radio could select and stayed hidden
  • NEW: A Settings link on the plugin’s row on the Plugins screen
  • FIXED: A visitor who may not rate is now told the actual reason. One template covers every refusal and it carried a single sentence written for one of them, so a site set to Guests Only refused a logged-in member and then told them to become a registered member — the one thing that would not have helped. The three reasons now read separately, and the sentence comes from a new %RATINGS_PERMISSION% variable. The update puts that variable into the stored Ratings No Permission Text in place of the old sentence, so an existing site gets the corrected wording without touching its settings — and a site that had reworded that sentence keeps its own wording untouched.
  • FIXED: The numbers shape drew its box two different ways — the sides as a border on the container, the top and bottom as inset shadows on the bar inside it. Same colour, but the sides fell on the page background while the top and bottom fell on the bar’s own tint, so the sides came out at several times the contrast and the box read as two heavy verticals with nothing joining them. All four edges are now drawn together, and the bar is no longer two pixels narrower than the box around it.
  • FIXED: Only one request at a time runs the outstanding upgrade. Until the plugin records itself as current the check runs on every front-end request, and the part of it that adds the log table’s indexes reads the table’s index list and then alters the table — so on a busy site two requests could both find an index missing and both try to add it, the second waiting on the first for as long as the alter took.
  • CHANGED: A stylesheet named wp-postratings.css in the parent theme now overrides the plugin’s copy too; a child theme’s copy still wins over both
  • FIXED: The comment author ratings display, which a theme opts into with the wp_postratings_display_comment_author_ratings filter, showed nothing at all on a block theme. It read the comment from a global that only a classic theme’s comment loop sets; a block theme renders each comment through the comment template block, which passes the comment along instead and leaves that global empty. The comment now comes from where the comment_text filter puts it, so the display works on both.
  • FIXED: The comment author ratings display, which is off unless a theme opts in, still cost its query: every page with a loop fetched every rating the displayed post had ever received, then threw them away. Sites that have not opted in no longer pay it — one query fewer on every page, and on a heavily rated post it was not a small one.
  • CHANGED: The stylesheet and script load only on pages that actually render a rating — from the template tags, the shortcode, the block, the widget, the statistics lists or the comment author display. Pages with no rating on them no longer carry either file; pages with one get both — in the head where the page’s content already shows a rating coming, in the footer for the renders the head cannot see.
  • FIXED: Nothing unpublished could be rated by anybody, including the people who wrote it. 2.0.0 required a post to be publicly viewable before it would accept a rating — which stops a stranger rating your drafts, and was the point — but it never asked who was rating, so a site whose editors rate their own drafts, pending or private posts got Invalid Post ID on every vote. A post you can already read is now ratable whether or not the public can see it, and the message no longer blames the post ID, which is rarely what is wrong with it.
  • NEW: wp_postratings_is_ratable filters whether a given post may be rated at all, for sites whose answer is neither of the two above.
  • CHANGED: The REST error code for a post that may not be rated is wp_postratings_not_ratable rather than wp_postratings_no_such_post. The status is still 404, deliberately: a 403 would tell a stranger that the draft exists.

2.0.0

  • FIXED: Any post ID could be rated, not only a published one. A visitor who was never signed in could seed ratings_users, ratings_score and ratings_average onto a draft, a pending, a private or a trashed post — so it arrived already rated on the day it was published — and the unpublished title was copied into the log table, where the Logs screen then displayed it. On a site that had put %POST_TITLE% or %POST_CONTENT% into the text template, the reply returned unpublished content directly. Both the AJAX action and the REST route now require a post that is actually publicly viewable
  • NEW: A wp postratings WP-CLI command — list, get and delete, with --what=logs|data|both.
  • NEW: A postratings/v1 REST API for reading a post’s rating and casting one. The admin-ajax.php wp_postratings action is unchanged and still supported.
  • NEW: A Ratings block for the editor, with the post id and a results-only toggle in the sidebar. It renders on the server through the same code the shortcode does, so the editor preview is the real rating. The [ratings] shortcode is unchanged and still supported — the block is an addition beside it, nothing needs migrating, and posts already holding a shortcode need no edit.
  • BREAKING: Requires WordPress 6.8 and PHP 8.2.
  • BREAKING: The rating images are gone. All 16 image sets and their 121 GIF and PNG files are replaced by 10 shapes drawn with CSS, so ratings are sharp on every screen and cost no HTTP requests. Your chosen set is migrated automatically to the matching shape: stars, stars_crystal, stars_dark, stars_png and stars_flat_png all become star, thumbs becomes thumb, and so on. If you added your own folder to images/ it will fall back to stars; see the FAQ for how to register a custom shape properly, which unlike the old folder survives an update.
  • BREAKING: The rating markup has changed completely. A scale is now a group of radio buttons and an up/down is a pair of buttons, so the control announces itself correctly to screen readers and works from the keyboard. Every class and element id is now prefixed with the plugin slug: .post-ratings is .wp-postratings, .post-ratings-image no longer exists at all, and the wrapper id is wp-postratings-123 rather than post-ratings-123. Colour, size and spacing are CSS custom properties, which is usually a one-line replacement; see the FAQ.
  • BREAKING: The vote images no longer carry inline onmouseover/onclick attributes; hovering and clicking are handled by one delegated listener. Custom CSS or JavaScript that targeted those inline handlers, or that called current_rating() or rate_post() directly, needs updating.
  • BREAKING: The rate_post action is renamed wp_postratings_rate_post and the old name is gone, with no deprecation shim. Its three arguments are unchanged.
  • BREAKING: Every class is renamed to WP_PostRatings_*, and the plugin’s own classes are no longer called Postratings_*. RATINGS_IMG_EXT is now WP_POSTRATINGS_IMG_EXT.
  • BREAKING: The settings screen moved to WP-Admin -> Ratings -> Settings, at admin.php?page=wp-postratings-settings. Settings and Templates are the two tabs of that one page rather than two menu entries.
  • BREAKING: The option rows are renamed. The fifteen postratings_* rows become one wp_postratings_options, and the two separate version markers become one wp_postratings_version. Your settings are migrated automatically on the first load after the update.
  • BREAKING: The shared, unprefixed stats_display and stats_mostlimit option rows are no longer read. WP-Stats integration is now two settings of this plugin’s own, on the Settings tab, and WP-Stats asks each plugin for its section through the wp_stats_sections filter rather than reading anybody’s options. Update all seven WP-Stats-aware plugins together; see the Upgrade Notice.
  • BREAKING: If you set “Header That Contains The IP” (for Cloudflare, a load balancer or any reverse proxy), that header is now parsed as the forwarded-for chain it is, and only the first valid address in it is used. Previously the whole header value was stored, so a visitor could rate repeatedly just by appending another address to it. Existing rating logs recorded through such a header will no longer match, so some visitors may be able to rate once more. Leave the field blank unless you are actually behind a proxy. See the FAQ.
  • BREAKING: “Ratings Logging Method” is now “Check For Repeat Votes”, and it no longer decides whether anything is logged. It never did anything but choose what a returning visitor is matched against, and the two readings pointed opposite ways: a site that picked “Do Not Log” or “Logged By Cookie” got no ratings log, no rows on the logs screen and no WP-Stats figures, which is not what either choice sounds like. Every vote is now recorded whatever this is set to. The choices read “Do Not Check”, “Check By Cookie”, “Check By IP Address”, “Check By Cookie And IP Address” and “Check By Username”; the stored numbers are unchanged, so your setting means what it always meant. The option key inside wp_postratings_options is check_method rather than logging_method, migrated automatically.
  • BREAKING: The wp_postratings_always_log filter is gone. It asked for exactly the behaviour above, which is now the default, and a filter that forces the default does nothing. Sites that would rather not keep the record have the opposite filter instead: return false from wp_postratings_log_rating and no row is written. The post’s own score and vote count are post meta and are updated either way.
  • BREAKING: The stylesheet is now wp-postratings.css, not postratings-css.css, and there is no separate RTL stylesheet. If your theme ships its own postratings-css.css override it will no longer be picked up; rename it, or better, use the colour setting and the CSS custom properties instead.
  • NEW: Rewritten as classes under includes/, so the plugin now works installed under any directory name.
  • NEW: Settings moved to the WordPress Settings API, with the options and templates screens merged into one tabbed page.
  • NEW: The rating log is now a standard WordPress list table, with sortable columns, bulk delete, a search box and Screen Options.
  • NEW: The scripts are vanilla JavaScript; the jQuery dependency is gone, and hovering the stars is pure CSS, so nothing runs on mouse move at all.
  • NEW: Rating colours are a setting, per rating rather than per site: each row of the rating table has its own rated and not-rated colour, with a Reset to default beside them. This replaces the old colour variants of the image sets, where changing colour meant choosing a different set of files.
  • NEW: wp_postratings_shapes lets you register your own rating shape.
  • NEW: WP_POSTRATINGS_TRUST_PROXY and the wp_postratings_trust_proxy filter opt into the usual reverse-proxy headers without naming one. “Header That Contains The IP” stays the narrow answer — exactly the one header your proxy sets — and still wins when both are given; the constant is the broad one, meaning “try the seven headers proxies commonly use”. WP-Email, WP-Polls, WP-Ban and WP-UserOnline already worked this way; WP-PostRatings was the one that did not.
  • NEW: wp_postratings_capability filters the capability the plugin’s screens require, which is still manage_ratings.
  • NEW: The stylesheet honours prefers-color-scheme: dark, prefers-contrast: more and prefers-reduced-motion: reduce.
  • CHANGED: Ratings display a true percentage instead of being rounded to the nearest half image, so an average of 3.7 out of 5 now fills 74% of the stars rather than showing three and a half.
  • CHANGED: RATINGS_IMG_EXT and wp_postratings_image_extension no longer choose anything; there are no image files left to have an extension. The wp_postratings_ratings_image_alt filter stays, but it now sets the rating’s accessible label rather than an image’s alt and title text.
  • FIXED: The plugin requested an admin stylesheet that had been an empty file since 2020.
  • FIXED: The per-post lock file was never released, so one was left behind in the server’s temporary directory on every single rating.
  • FIXED: Uninstalling on a multisite network stopped after the first 100 sites, leaving the options and the rating table behind on every site after that.
  • FIXED: Activating network-wide also stopped after 100 sites.
  • FIXED: A rating outside the configured scale was recorded as a vote worth nothing, and warned on PHP 8.
  • FIXED: Comment author ratings never matched by IP, so they had been silently broken since ratings began being stored hashed.
  • FIXED: The “numbers” rating image set could not be saved; it reported success and reverted to stars.
  • FIXED: Post titles containing an apostrophe were stored in the log with a stray backslash.
  • FIXED: The rating log always claimed to be sorted “Descending” whichever order was chosen.
  • FIXED: Deleting all rating data left every post’s cache holding the values that had just been removed.
  • FIXED: Numerous PHP 8 warnings on the admin screens and in an unconfigured widget.
  • NEW: When an up/down post has no verdict to show, it shows you your own vote instead. A tie points nowhere, so rating a post down and landing on one drew a blank pair that looked exactly like the control you had just clicked — as though the vote had not been recorded. Your vote is the only direction that can honestly be attributed at that point, so it takes the shape and the label reads “You rated this down”. A post that does have a verdict keeps showing it: one that is 500 to 3 in favour must not read as a thumbs down to the single visitor who disagreed. Your vote comes from the “already rated” cookie, or from the rating log when the repeat-vote check is by username. It is deliberately never matched by IP address: behind a proxy or a mobile network many visitors share one address, so that would tell somebody who had never voted that they had
  • FIXED: An up/down rating with no verdict was drawn as a vote down. Zero is not a direction: a post nobody has rated, and a post with as many down votes as up, both average zero, and both showed a lit thumbs down. They now show the pair unlit. This also fixes what a site sees after switching from a scale to an up/down control — an up/down vote is worth -1 or +1, so a score off a scale of stars is far too large to be one, and reading it as a direction showed every previously rated post as a thumbs up that no amount of voting down could shift. Such a post now shows the unlit pair until its up/down votes outweigh its history, and the vote count and score are reported exactly as stored throughout
  • FIXED: On a dark colour scheme the unrated shapes stayed the light grey chosen for a light page, and glared. The dark default is a custom property set on the container the_ratings() adds — but the widget, and the shortcode and block when asked for results only, print the rating without that container, so nothing they drew ever inherited it. The same was true of the high-contrast default

Try other plugins

Yoast SEO icon

Yoast SEO

4.8 · 10M+ installs

Improve your WordPress SEO: Write better content and have a fully optimized WordPress site using the Yoast SEO…