WP_Comment_Query
- Since
- 3.1.0
- Source
wp-includes/class-wp-comment-query.php:17
Core class used for querying comments.
Compatibility
- WordPress
- since 3.1.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Hooks and filters fired · 6
Every hook that fires from inside WP_Comment_Query, in the order it appears in the class, grouped by the method that fires it.
WP_Comment_Query::get_comments()
- do_action( pre_get_comments )action line 394
- apply_filters( comments_pre_query )filter line 434
- apply_filters( the_comments )filter line 522
Properties · 11
$requeststringpublic- SQL for database query.
$meta_queryWP_Meta_Querypublic- Metadata query container
$meta_query_clausesarrayprotected- Metadata query clauses.
$sql_clausesarrayprotected- SQL query clauses.
$filtered_where_clausestringprotected- SQL WHERE clause.
$date_queryWP_Date_Querypublic- Date query container
$query_varsarraypublic- Query vars set by the user.
$query_var_defaultsarraypublic- Default values for query vars.
$commentsint[]|WP_Comment[]public- List of comments located by the query.
$found_commentsintpublic- The amount of found comments for the current query.
$max_num_pagesintpublic- The number of pages.
Methods · 11
- __call()Make private/protected methods readable for backward compatibility.
- __construct()Constructor.
- parse_query()Parse arguments passed to the comment query with default query parameters.
- query()Sets up the WordPress query for retrieving comments.
- get_comments()Get a list of comments matching the query vars.
- get_comment_ids()Used internally to get a list of comment IDs matching the query vars.
- set_found_comments()Populates found_comments and max_num_pages properties for the current query if the limit clause was used.
- fill_descendants()Fetch descendants for located comments.
- get_search_sql()Used internally to generate an SQL string for searching across multiple columns.
- parse_orderby()Parse and sanitize 'orderby' keys passed to the comment query.
- parse_order()Parse an 'order' query variable and cast it to ASC or DESC as necessary.
Source code
#[AllowDynamicProperties]class WP_Comment_Query { /** * SQL for database query. * * @since 4.0.1 * @var string */ public $request; /** * Metadata query container * * @since 3.5.0 * @var WP_Meta_Query A meta query instance. */ public $meta_query = false; /** * Metadata query clauses. * * @since 4.4.0 * @var array */ protected $meta_query_clauses; /** * SQL query clauses. * * @since 4.4.0 * @var array */ protected $sql_clauses = array( 'select' => '', 'from' => '', 'where' => array(), 'groupby' => '', 'orderby' => '', 'limits' => '', ); /** * SQL WHERE clause. * * Stored after the {@see 'comments_clauses'} filter is run on the compiled WHERE sub-clauses. * * @since 4.4.2 * @var string */ protected $filtered_where_clause; /** * Date query container * * @since 3.7.0 * @var WP_Date_Query A date query instance. */ public $date_query = false; /** * Query vars set by the user. * * @since 3.1.0 * @var array */ public $query_vars; /** * Default values for query vars. * * @since 4.2.0 * @var array */ public $query_var_defaults; /** * List of comments located by the query. * * @since 4.0.0Changelog
Introduced in 3.1.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/class-wp-comment-query.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.