get_comments() WordPress Function

The get_comments() function is used to retrieve the comments for a post or page. This function can be used within the loop or outside of the loop.

get_comments( string|array $args = '' ) #

Retrieves a list of comments.


Description

The comment list can be for the blog as a whole or for an individual post.


Top ↑

Parameters

$args

(string|array)(Optional) Array or string of arguments. See WP_Comment_Query::__construct() for information on accepted arguments.

Default value: ''


Top ↑

Return

(WP_Comment[]|int[]|int) List of comments or number of found comments if $count argument is true.


Top ↑

Source

File: wp-includes/comment.php

function get_comments( $args = '' ) {
	$query = new WP_Comment_Query;
	return $query->query( $args );
}


Top ↑

Changelog

Changelog
VersionDescription
2.7.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
Show More