I was learning from the WordPress codex about global variables and after
var_dump($post) I found out that
$post has a property called
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?
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
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
the output from
get_comments_number() is filterable should you later need to filter the output