Skip to content

Instantly share code, notes, and snippets.

@furahaclothing
Created May 15, 2013 08:39
Show Gist options
  • Save furahaclothing/5582479 to your computer and use it in GitHub Desktop.
Save furahaclothing/5582479 to your computer and use it in GitHub Desktop.
wp-customer-review レビュー件数の表示(function.phpに記載)
function get_reviews_count( $status, $pageid) {
global $wpdb;
$returnvalue = 0;
if ($status == -1) {
$qry_status = '1=1';
} else {
$qry_status = "`status`=$status";
}
$sql = "SELECT COUNT(*) AS `total` FROM `wp_wpcreviews` WHERE $qry_status AND `page_id`=".$pageid;
$total_reviews = $wpdb->get_results($sql);
if (count($total_reviews) == 0)
{
return $returnvalue;
}
else
{
return $total_reviews[0]->total;
}
}
--------------------------------
//表示させたい部分に記載
<?php $rc = get_reviews_count(1, 102); echo ($rc == 1) ? "$rc review" : "$rc reviews"; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment