Title: WP_Query::have_comments
Published: April 25, 2014
Last modified: August 20, 2026

---

# WP_Query::have_comments(): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_query/have_comments/?output_format=md#description)
 * [Return](https://developer.wordpress.org/reference/classes/wp_query/have_comments/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_query/have_comments/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_query/have_comments/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_query/have_comments/?output_format=md#changelog)

Determines whether there are more comments available.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_query/have_comments/?output_format=md#description)󠁿

Automatically rewinds comments when finished.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_query/have_comments/?output_format=md#return)󠁿

 bool True if comments are available, false if no more comments.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_query/have_comments/?output_format=md#source)󠁿

    ```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;
    }
    ```

[View all references](https://developer.wordpress.org/reference/file/wp-includes/class-wp-query.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-query.php#L3934)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-query.php#L3934-L3942)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_query/have_comments/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Query::rewind_comments()](https://developer.wordpress.org/reference/classes/wp_query/rewind_comments/)`wp-includes/class-wp-query.php` |

Rewinds the comments, resets the comment index and comment to first.

  |

| Used by | Description | 
| [have_comments()](https://developer.wordpress.org/reference/functions/have_comments/)`wp-includes/query.php` |

Determines whether current WordPress query has comments to loop over.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_query/have_comments/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.2.0](https://developer.wordpress.org/reference/since/2.2.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fsummer-heart-0930.chufeiyun1688.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_query%2Fhave_comments%2F)
before being able to contribute a note or feedback.