• Resolved sordinn

    (@sordinn)


    I have the following function on my functions.php. when I call the [count_site_reviews], I get 0. Is there anything wrong with my function?

    "

    add_shortcode('count_site_reviews', function () {

        global $wpdb;

        // Query the database to count all reviews in Site Reviews

        $total_reviews = $wpdb->get_var("

            SELECT COUNT(*)

            FROM {$wpdb->posts}

            WHERE post_type = 'glsr' -- Check if this is the correct post type

            AND post_status IN ('publish', 'approved') -- Include published or approved statuses

        ");

        // Return the total count

        return sprintf('Total reviews: %d', intval($total_reviews));

    });

    "
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    Use the glsr_get_ratings function.

    add_shortcode('count_site_reviews', function () {
    $info = apply_filters('glsr_get_ratings', 0, [
    'status' => 'approved',
    ]);
    return $info->reviews ?? 0;
    });
    Thread Starter sordinn

    (@sordinn)

    Thank you so much, that worked great

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Getting review count’ is closed to new replies.