niemand_0,
Yes so as long as you are calling the functions from a location that will run after plugins have been loaded you should be able to access the global Rich Reviews instance. So the plugin loads an instance of the Rich Reviews controller class to the global variable $richReviews
. Further, the easiest way to access the data you’re looking for would be through the DB query function used for the snippet. This function requires a category argument, and a post object argument. If you want to count all reviews regardless of category, you can pass 'any'
as the first argument. Then since you are going to be using this inside of a template file, I assume you will be counting the reviews submitted on the current page, so you should just be able to access the global $post
and pass that as the post argument. This will return an array of data in the following format:
Array (
['average'] => AVERAGE,
['reviews_count'] => COUNT,
['category'] => CATEGORY
);
I would recommend wrapping any code using the $richReviews
global in existence checks to avoid your site being white-screened in the case that the plugin is not present. However, this should more or less be the code that you are looking for.
<?php
// call the needed global vars
global $richReviews, $post;
var $reviewData = $richReviews->db->get_average_rating('any', $post);
$reviewCount = $reviewData['reviewsCount'];
// $reviewsCount is now a String representation of the number of reviews submitted for this page.
?>