I will try to keep this short and simple as possible.
My website uses listings (instead of posts) because I have a directory page theme (MyListing – this one). I review restaurants and add reviews through “Let’s Review” plugin (API documentation is here). When I review a listing the plugin adds a review box in the listing, showing pros and cons and the final score. It looks something like this:
What I would like is to get that final score (7.8 in this case) in raw form, without design and put it in the listing template on the top above the content (I will put it into the listing template because every listing will have a review and this box). I don’t need help where in the listing template to add it, I will do that myself once I find out how to call this API code.
The ‘Let’s Review’ theme does have API support and I did find the part of code which (I think) should suit me:
if ( class_exists( 'Lets_Review_API' ) ) {
$lets_review_api = new Lets_Review_API();
$lets_review_final_score = $lets_review_api->lets_review_get_final_score( $postid );
}
If I pressume correctly, this snippet calls the post ID and shows the final score in raw form. That’s what I want! But here is the problem. As I understood the part “Ensure you are calling it from inside the WordPress post loop” it means I have to add this code to functions.php of the theme. But everything else is beyond me. I don’t know how to call this final score in the raw form in my listing template? The documentation also states “You must pass a valid post id to the method to get the correct data” but I don’t know how.
Did I do the right thing to add this code to functions.php? And which code to add to my listing template (listing.php) so it will, as I pressume, fetch the post ID and show the raw score of that review.
Any help (or taking me into the right direction) is appreciated.