Getting review count
-
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)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Getting review count’ is closed to new replies.
