I'm trying to call the post_hits value from the wp_site_posts table (as part of Post Indexer plugin) on the post page (index.php). I'm using the following query:
<?php echo $wpdb->get_var("SELECT post_hits FROM " . $wpdb->base_prefix . "site_posts WHERE post_id = '" . $post->ID . "'");
The problem is the code only sort of works. On some posts it returns the correct value from the wp_site_posts table, but on others it is completely off, usually returning a much higher amount of hits than the post actually has. Why could this be?