Created
May 15, 2013 08:39
-
-
Save furahaclothing/5582479 to your computer and use it in GitHub Desktop.
wp-customer-review レビュー件数の表示(function.phpに記載)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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