query.get_comments

/ Database / query.get_comments

Title : query.get_comments
Purpose : Retrieve a list of comments.
Syntax : [query.get_comments o.exit=d]
{
“post_type”: “notification_tpl”
}
[/query.get_comments]
Input Parameters :

(string|array) (Optional) Array or query string of comment query parameters.

  • ‘author_email’
    (string) Comment author email address.
  • ‘author_url’
    (string) Comment author URL.
  • ‘author__in’
    (array) Array of author IDs to include comments for.
  • ‘author__not_in’
    (array) Array of author IDs to exclude comments for.
  • ‘comment__in’
    (array) Array of comment IDs to include.
  • ‘comment__not_in’
    (array) Array of comment IDs to exclude.
  • ‘count’
    (bool) Whether to return a comment count (true) or array of comment objects (false). Default false.
  • ‘date_query’
    (array) Date query clauses to limit comments by. See WP_Date_Query. Default null.
  • ‘fields’
    (string) Comment fields to return. Accepts ‘ids’ for comment IDs only or empty for all fields.
  • ‘ID’
    (int) Currently unused.
  • ‘include_unapproved’
    (array) Array of IDs or email addresses of users whose unapproved comments will be returned by the query regardless of $status.
  • ‘karma’
    (int) Karma score to retrieve matching comments for.
  • ‘meta_key’
    (string) Include comments with a matching comment meta key.
  • ‘meta_value’
    (string) Include comments with a matching comment meta value. Requires $meta_key to be set.
  • ‘meta_query’
    (array) Meta query clauses to limit retrieved comments by. See WP_Meta_Query.
  • ‘number’
    (int) Maximum number of comments to retrieve. Default empty (no limit).
  • ‘paged’
    (int) When used with $number, defines the page of results to return. When used with $offset, $offset takes precedence. Default 1.
  • ‘offset’
    (int) Number of comments to offset the query. Used to build LIMIT clause. Default 0.
  • ‘no_found_rows’
    (bool) Whether to disable the SQL_CALC_FOUND_ROWS query. Default: true.
  • ‘orderby’
    (string|array) Comment status or array of statuses. To use ‘meta_value’ or ‘meta_value_num’, $meta_key must also be defined. To sort by a specific $meta_query clause, use that clause’s array key. Accepts ‘comment_agent’, ‘comment_approved’, ‘comment_author’, ‘comment_author_email’, ‘comment_author_IP’, ‘comment_author_url’, ‘comment_content’, ‘comment_date’, ‘comment_date_gmt’, ‘comment_ID’, ‘comment_karma’, ‘comment_parent’, ‘comment_post_ID’, ‘comment_type’, ‘user_id’, ‘comment__in’, ‘meta_value’, ‘meta_value_num’, the value of $meta_key, and the array keys of $meta_query. Also accepts false, an empty array, or ‘none’ to disable ORDER BY clause. Default: ‘comment_date_gmt’.
  • ‘order’
    (string) How to order retrieved comments. Accepts ‘ASC’, ‘DESC’. Default: ‘DESC’.
  • ‘parent’
    (int) Parent ID of comment to retrieve children of.
  • ‘parent__in’
    (array) Array of parent IDs of comments to retrieve children for.
  • ‘parent__not_in’
    (array) Array of parent IDs of comments *not* to retrieve children for.
  • ‘post_author__in’
    (array) Array of author IDs to retrieve comments for.
  • ‘post_author__not_in’
    (array) Array of author IDs *not* to retrieve comments for.
  • ‘post_ID’
    (int) Currently unused.
  • ‘post_id’
    (int) Limit results to those affiliated with a given post ID. Default 0.
  • ‘post__in’
    (array) Array of post IDs to include affiliated comments for.
  • ‘post__not_in’
    (array) Array of post IDs to exclude affiliated comments for.
  • ‘post_author’
    (int) Post author ID to limit results by.
  • ‘post_status’
    (string|array) Post status or array of post statuses to retrieve affiliated comments for. Pass ‘any’ to match any value.
  • ‘post_type’
    (string) Post type or array of post types to retrieve affiliated comments for. Pass ‘any’ to match any value.
  • ‘post_name’
    (string) Post name to retrieve affiliated comments for.
  • ‘post_parent’
    (int) Post parent ID to retrieve affiliated comments for.
  • ‘search’
    (string) Search term(s) to retrieve matching comments for.
  • ‘status’
    (string|array) Comment stati to limit results by. Accepts an array or space/comma-separated list of ‘hold’ (comment_status=0), ‘approve’ (comment_status=1), ‘all’, or a custom comment status. Default ‘all’.
  • ‘type’
    (string|array) Include comments of a given type, or array of types. Accepts ‘comment’, ‘pings’ (includes ‘pingback’ and ‘trackback’), or anycustom type string.
  • ‘type__in’
    (array) Include comments from a given array of comment types.
  • ‘type__not_in’
    (array) Exclude comments from a given array of comment types.
  • ‘user_id’
    (int) Include comments for a specific user ID.
  • ‘hierarchical’
    (bool|string) Whether to include comment descendants in the results. ‘threaded’ returns a tree, with each comment’s children stored in a children property on the WP_Comment object. ‘flat’ returns a flat array of found comments plus their children. Pass false to leave out descendants. The parameter is ignored (forced to false) when $fields is ‘ids’ or ‘counts’. Accepts ‘threaded’, ‘flat’, or false. Default: false.
  • ‘cache_domain’
    (string) Unique cache key to be produced when this query is stored in an object cache. Default is ‘core’.
  • ‘update_comment_meta_cache’
    (bool) Whether to prime the metadata cache for found comments. Default true.
  • ‘update_comment_post_cache’
    (bool) Whether to prime the cache for comment posts. Default false.

Default value: ”

Return Value :
(int|array) List of comments or number of found comments if count the argument is true.

Example 1 :
Code : [query.get_comments o.exit=d]
{
“post_type”: “notification_tpl”
}
[/query.get_comments]
Output : (int|array) List of comments or number of found comments if count the argument is true.
Description : The comment list can be for the blog as a whole or for an individual post.
Categories
Most Popular

Leave a Reply

Your email address will not be published. Required fields are marked *