WordPress at a glance
function is not described

WP_Comment_Query::set_found_comments() WP 4.6.0

Populates found_comments and max_num_pages properties for the current query if the limit clause was used.

This is a method of the class: WP_Comment_Query

Hooks from the method

Null. Nothing.


$WP_Comment_Query = new WP_Comment_Query();
$var = $WP_Comment_Query->set_found_comments();


  • Global. wpdb. $wpdb WordPress database abstraction object.


Since 4.6.0 Introduced.

Code of WP Comment Query::set found comments: wp-includes/class-wp-comment-query.php WP 5.2.4

private function set_found_comments() {
	global $wpdb;

	if ( $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) {
		 * Filters the query used to retrieve found comment count.
		 * @since 4.4.0
		 * @param string           $found_comments_query SQL query. Default 'SELECT FOUND_ROWS()'.
		 * @param WP_Comment_Query $comment_query        The `WP_Comment_Query` instance.
		$found_comments_query = apply_filters( 'found_comments_query', 'SELECT FOUND_ROWS()', $this );

		$this->found_comments = (int) $wpdb->get_var( $found_comments_query );