Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )

I was learning from the WordPress codex about global variables and after

var_dump($post) I found out that $post has a property called comment_count

I was wondering whether I can directly use $post->comment_count instead of get_comments_number( $post_id ) inside the loop? Or does it have any disadvantage?

Solutions Collecting From Web of "Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )"

This is that classic question, do you have 6 eggs or half a dozen, and frankly, it doesn’t actually matter.

It is however better to use get_comments_number() because

  • the post object is retrieved from the $GLOBALS['post'] global which is set by the_post() inside the loop

  • the post object is validated through WP_Post (through get_post())

  • the output from get_comments_number() is filterable should you later need to filter the output