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.


Top ↑

Return

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


Top ↑

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


Top ↑

Changelog

Changelog
VersionDescription
2.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More