Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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