Hey Lemon,
This might be what you’re looking for (note that this modifies the plugin code, which would be lost when upgrading):
Open wp-customer-reviews.php, and find the following line:
$the_content .= '<div id="wpcr_respond_1">'; /* start the div */
and add this directly below that:
global $wpdb;
$row = $wpdb->get_results("SELECT COUNT(*) AS 'total' FROM '$this->dbtable' WHERE 'page_id'=$post->ID AND 'status'=1");
$the_content .= $row[0]->total . ' Reviews';
Thread Starter
Lee
(@mylemonhead)
thanks for the reply Demoris, i did that but it did not register a count. It just appears Reviews, with any numbers. Any idea?
That works for me on my dev site. Do you have any reviews yet, or are they at 0 reviews?
I have the same question.. Is there any way to show how many reviews has each posts?
Let me know please..
After a few hours of research I discovered that Demoris solutions works perfectly. You only have to change the single qoute (‘) with backtick (`) in select statement, at table ($this->dbtable) and fields (page_id and status) names.
I’ve tested WPCR 2.4.5 on WP 3.2.
Thread Starter
Lee
(@mylemonhead)
i almost forgot about this, thanks sorinaba for making it work! for those who want the edited.. here goes
global $wpdb;
$row = $wpdb->get_results("SELECT COUNT(*) AS 'total' FROM <code>$this->dbtable</code> WHERE <code>page_id</code>=$post->ID AND <code>status</code>=1");
$the_content .= $row[0]->total . ' Reviews';
Anyone knows the function to echo out the total number of reviews?
Hello,
I want to show it in the “contents.php” the number of reviews,
I have written a code like this,
<? php
global $ wpdb;
$ row = $ wpdb-> get_results ("SELECT COUNT (*) AS 'total' FROM 'wp_wpcreviews' WHERE 'page_id' = $ post-> ID AND 'status' = 1");
$ the_content = $ row [0] -> total 'Reviews';
?>
</ code>
It appears simply as “Array” then.
How can you do that “contents.php” How do I reflect the number of good reviews?`
global $wpdb;
$row = $wpdb->get_results("SELECT page_id, status FROM wp_wpcreviews WHERE page_id = $post->ID AND status = 1");
$the_content .= $wpdb->num_rows . ' Reviews';
$wpdb->flush();
Basically I just removed the single quotes, they are not necessary, and selected 2 fields used to filter, then used $wpdb->num_rows variable to count the rows, and of course, added the flush() method to clean up the $wpdb query after we are done.
Thanks wayway1001
It worked! I am a beginner in PHP, I was really in trouble.
Thank you again!
To show total / aggregate ratings and reviews, I have wrote custom code for this plugin that will work on any page.
Check this out: http://ka.lpe.sh/2012/10/22/wordpress-show-total-aggregate-ratings-and-reviews-to-your-posts-pages/