Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Created March 27, 2019 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaineLabs/35ae10fd240256c525a8e3f4d20197cd to your computer and use it in GitHub Desktop.
Save KaineLabs/35ae10fd240256c525a8e3f4d20197cd to your computer and use it in GitHub Desktop.
Total Reviews Shortcode [yz_total_reviews user_id=""]
<?php
/**
* Get User Reviews Count.
*/
function yzc_get_total_reviews_shortcode( $args = null ) {
global $bp, $wpdb, $Yz_reviews_table;
// Get Shortcode Args.
$args = wp_parse_args( $args, array(
'user_id' => false,
)
);
// Get Global Request
$request = "SELECT COUNT(*) FROM {$Yz_reviews_table}";
if ( ! empty( $args['user_id'] ) ) {
$request .= " WHERE reviewed = {$args['user_id']}";
}
return $wpdb->get_var( $request );
}
add_shortcode( 'yz_total_reviews', 'yzc_get_total_reviews_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment