W3cubDocs

/WordPress

WP_Comment_Query::set_found_comments()

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

Source

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 );
	}
}

Hooks

apply_filters( ‘found_comments_query’, string $found_comments_query, WP_Comment_Query $comment_query )

Filters the query used to retrieve found comment count.

Changelog

Version Description
4.6.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_comment_query/set_found_comments