Comment count same for every post in homepage WP_Query

I have a WP_Query on my homepage template that works just fine for get_the_title() and MANY other functions for each post in the loop.

However, any way of getting the comment count just grabs the real count for the first post and then repeats the same output for the rest of the posts.

I've tried both echo get_comments_number($post-ID); and comments_number();

The kicker: if I use the same template NOT on the homepage, comment count works fine.

Topic wp-query Wordpress

Category Web


Switching out echo get_comments_number($post->ID) for echo $post->comment_count did the trick.

I have no idea why, that's exactly what the get_comments_number() function does...

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.