W3cubDocs

/WordPress

the_post()

Iterate the post index in the loop.

More Information

Basic Usage

if ( have_posts() ) {
	while ( have_posts() ) {

		the_post(); ?>

		<h2><?php the_title(); ?></h2>

		<?php the_content(); ?>

	<?php }
}

Source

File: wp-includes/query.php

function the_post() {
	global $wp_query;
	$wp_query->the_post();
}

Changelog

Version Description
1.5.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/the_post