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.
Parameters
- $args
(string|array)(Optional) Array or string of arguments. See WP_Comment_Query::__construct() for information on accepted arguments.
Default value: ''
Return
(WP_Comment[]|int[]|int) List of comments or number of found comments if $count
argument is true.
Source
File: wp-includes/comment.php
function get_comments( $args = '' ) { $query = new WP_Comment_Query; return $query->query( $args ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
2.7.0 | Introduced. |