Here’s something I’d use if I want to do that without using plugins
Create a custom field as rating
and provide the value while doing post. Suppose I gave a rating of 6, Now wordpress save it into the database as.
meta_key
=> ratingmeta_value
=> 6
Now to show the rating on post I’ll use this code into single.php
or index.php
but make sure to put it within WordPress loop
–
<?php
//grab the rating value
$rating = get_post_meta($post->ID, 'rating', true);
//prints star image
for ($i=1; $i<=$rating; $i++){
echo '<img src="https://wordpress.stackexchange.com/questions/60695/LINK-TO-STAR-ICON"/>';
}
//prints unstar image
for ($i=$rating; $i<10; $i++){
echo '<img src="LINK-TO-UNSTAR-ICON"/>';
}
?>
The above code will result like this –