How to show in Google only good ratings for the Rate my Post plugin

The Rate my Post plugin is one of the best there is for user ratings of your content, with the added bonus that you can assign structured Schema data to your content that will highlight it in search engine results.

But what happens if you have bad ratings in your content? do you also want your content to appear in Google with bad ratings? will you be penalized for showing results with 2 stars or less?

I think this question has come up for all of us, and the reality is that normally yes, a snippet enriched with structured data that shows a bad rating will normally receive fewer clicks than another one that shows better ratings.

Wouldn’t it be great if only the plugin’s ratings in the structured data are shown in Google if they have 3 stars or more?

Well, it’s easy, thanks to these simple lines of code:

/* Don't generated structured data below 3 stars average */
function wphelp_structured_data_ratemypost_low( $structuredData ) {
if( (rmp_get_avg_rating() * 10 ) < 30) {
return ''; 
}
return $structuredData;
}
add_filter( 'rmp_structured_data', 'wphelp_structured_data_ratemypost_low' );Code language: PHP (php)

In the example code the Rate my Post plugin will only generate the structured data if the average rating of the content is higher than 3, so you can be sure to always show a good score in the search engine rich snippets.

The rest of the content, with a lower rating, will be shown in the search engine results, but without structured data showing (low) ratings, average votes or anything else, it will be a simple text snippet. Nothing will make it stand out, but nothing will penalize it either.

Here’s a quick and easy guide on how to use the above code, where to add it, that sort of thing…

How and where to paste PHP, JS, CSS codes and functions you find around in WordPress

How useful was this post?

Click on a smiley to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

About The Author

Leave a Comment

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

Scroll to Top
Skip to content