Access Total and Averages with Shortcode or Function
Starting at version 11.0.9 of the plugin you can now access the Total and Averages of a Badge, Template, or Source. You can output on the Frontend with a Shortcode or you can access it with a function.
Shortcode:
[wprevpro_totalavg pid="pageid" attb="attribute"]
You can find the pageid and attribute values to use by going to the Badges tab and clicking the Badge Datas button.
The attribute values are:
total_db
total_source
avg_db
avg_source
num1
num2
num3
num4
num5
For example, if I wanted to just display the Review List Avg for LJ Apps in the screenshot above, I would use this Shortcode on my page or in a text widget:
[wprevpro_totalavg pid="777685579067930" attb="avg_db"]
Function:
You can also access an array of all data for a Page ID with the following function...
wprevpro_gettotalavgs($pageid);
So for example, if I wanted to print out an array of all the values for my LJ Apps page above I could add this to my functions.php file in my theme or another plugin...
print_r(wprevpro_gettotalavgs('777685579067930'));
Which would bring back something like this...
Array ( [btp_id] => 1249 [btp_name] => Huxley Stay Sun Safe SPF 50+ PA++++ [btp_type] => page [pagetype] => WooCommerce [pagetypedetails] => [total_indb] => 9 [total] => 0 [avg_indb] => 3.444 [avg] => [numr1] => 2 [numr2] => 0 [numr3] => 3 [numr4] => 0 [numr5] => 4 )
Star Function:
Send the avg to this function to get the star html only. Useful if you just want to display the stars.
wprevpro_getstarhtml($avg);
The $avg is the average rating between 1-5. For example, if I wanted to output the star html I could combine the function above with this one like so...
<?php
$ratingvaluearray = wprevpro_gettotalavgs('777685579067930');
$starshtml = wprevpro_getstarhtml( $ratingvaluearray['avg_indb'] );echo $starshtml;
?>
Customer support service by UserEcho