Function Reference: geodir_count_reviews_by_term_id
Summary
Count reviews by term ID.
Global Values
- $wpdb
- (object) (required) WordPress Database object.
- Default: None
- $plugin_prefix
- (string) (required) Geodirectory plugin table prefix.
- Default: None
Package
GeoDirectory
Parameters
- $term_id
- (int) (required) The term ID.
- Default: None
- $taxonomy
- (int) (required) The taxonomy Id.
- Default: None
- $post_type
- (string) (required) The post type.
- Default: None
Return Values
- (int)
- Reviews count.
Change Log
Since: 1.0.0
1.5.1 Added filter to change SQL.
Filters
‘geodir_count_reviews_by_term_sql’ [Line: 3980]
Source File
geodir_count_reviews_by_term_id() is located in geodirectory-functions/general_functions.php [Line: 3963]
Source Code
function geodir_count_reviews_by_term_id( $term_id, $taxonomy, $post_type ) { global $wpdb, $plugin_prefix; $detail_table = $plugin_prefix . $post_type . '_detail'; $sql = "SELECT COALESCE(SUM(rating_count),0) FROM " . $detail_table . " WHERE post_status = 'publish' AND rating_count > 0 AND FIND_IN_SET(" . $term_id . ", " . $taxonomy . ")"; /** * Filter count review sql query. * * @since 1.5.1 * * @param string $sql Database sql query.. * @param int $term_id The term ID. * @param int $taxonomy The taxonomy Id. * @param string $post_type The post type. */ $sql = apply_filters( 'geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type ); $count = $wpdb->get_var( $sql ); return $count; }