Developers: Manual Post Rating Output

For developers who want to display a Post’s rating in a specific place, and do not wish to use Shortcodes, the below code can be used.

This could be used on your WordPress Theme’s Page, Post or Custom Post Template, but you are free to use this anywhere.

Parameter Accepted Value Description
enabled 0 Never display average rating
1 Only display average rating when ratings exist on this Page / Post / CPT
2 Always display average rating, regardless of whether ratings exist.
displaystyle Yellow stars only
grey Yellow stars with grey stars
displayaverage 0 Don’t display average rating
1 Display average rating using stars
2 Display average rating using bars
averageratingtext Value = the label text to display before the average rating
displaytotalratings 0 Do not display the total number of ratings made
1 Display the total number of ratings made
totalratingsbefore Value = the label text to display before the total rating
totalratingsafter Value = the label text to display after the total rating
displaybreakdown 0 Do not show the rating breakdown (if multiple rating fields exist, each field’s rating would be displayed)
1 Show the rating breakdown
displayratingnumber 0 Don’t display the rating number
1 Do display the rating number to the right of the star / bar as a number
2 Do display the rating percentage to the right of the star / bar as a percentage
filtercomments 0 Don’t allow each rating in the average to be clicked to filter comments by that rating.
1 Do allow each rating in the average to be clicked to filter comments by that rating.
displaylink 0 Don’t link the average rating text to the comments section.
1 Do link the average rating text to the comments section.
id Show the average rating for the Post/Page/Custom Post the shortcode is inserted into.
100 Show the average rating for the Post/Page/Custom Post with ID = 100.
cssID Optional ID to add to the main rating HTML markup.
cssClass Optional CSS class(es) to add to the main rating HTML markup.