By build this site we want to show up the ratings within the google results increase our CTR because the stars make the entry in the results in Google more visible. After trying out some WordPress-Plugins there was no Plugin that generating the needed Rich Text Snippet for the index page so we figured out how to get this but there was no plugin that serves the rating for the index page that passed the Rich Text Snippet Tool from Google
So we choosed Lester Chans WP-Rating that works fine for single articles and we use it as the base to generate the data for the index page.
But which data we can use ? The answer was easy and wI build a function that grab all single page rewiews and throws out a overall rating.
So you first step is to install the Plugin WP-PostRatings from Lester Chan and make sure it works fine.
So we added a following code-snippet to the functions.php of the theme :
function get_website_ranking() {
global $wpdb;
$rating_count = 0;
$wpdb->ratings = $wpdb->prefix.’ratings‘;
$my_ratings_results = $wpdb->get_results(„SELECT * FROM $wpdb->ratings“);
foreach($my_ratings_results as $my_ratings_result) {
$rating_vote = $my_ratings_result->rating_rating;
$rating_votes = $rating_votes + $rating_vote;
$rating_count++;
}
$text[0] = $rating_count;
$avg_count = $rating_votes/$rating_count;
$text[1] = number_format($avg_count,2);
return $text;
}
Now we have to put out the Rich Text Snippet on the index page – we place the following codes in the header.php, we put the code right after
[code]