WP_Query::next_post()publicWP 1.5.0

Sets up the next post and iterate current post index.

Method of the class: WP_Query{}

No Hooks.

Return

WP_Post. Next post.

Usage

global $wp_query;
$wp_query->next_post();

Changelog

Since 1.5.0 Introduced.

WP_Query::next_post() code WP 6.5.2

public function next_post() {

	++$this->current_post;

	/** @var WP_Post */
	$this->post = $this->posts[ $this->current_post ];
	return $this->post;
}