WP_Query::the_post()

In this article

Sets up the current post.

Description

Retrieves the next post, sets up the post, sets the ‘in the loop’ property to true.

Source

	 *
	 * @since 2.1.0
	 *
	 * @param string   $found_posts_query The query to run to find the found posts.
	 * @param WP_Query $query             The WP_Query instance (passed by reference).
	 */
	$found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) );

	$this->found_posts = (int) $wpdb->get_var( $found_posts_query );
} else {
	if ( is_array( $this->posts ) ) {
		$this->found_posts = count( $this->posts );
	} else {
		if ( null === $this->posts ) {
			$this->found_posts = 0;
		} else {
			$this->found_posts = 1;
		}
	}
}

/**
 * Filters the number of found posts for the query.
 *
 * @since 2.1.0
 *
 * @param int      $found_posts The number of posts found.
 * @param WP_Query $query       The WP_Query instance (passed by reference).
 */
$this->found_posts = (int) apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) );

if ( ! empty( $limits ) ) {

Changelog

VersionDescription
1.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.