WP_Query::have_comments() WordPress Method
The have_comments() method for WP_Query checks whether any comments exist for the current post. This is useful for determining whether to display the comment form or not.
WP_Query::have_comments() #
Whether there are more comments available.
Description
Automatically rewinds comments when finished.
Return
(bool) True if comments are available, false if no more comments.
Source
File: wp-includes/class-wp-query.php
public function have_comments() {
if ( $this->current_comment + 1 < $this->comment_count ) {
return true;
} elseif ( $this->current_comment + 1 == $this->comment_count ) {
$this->rewind_comments();
}
return false;
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 2.2.0 | Introduced. |