the_post() WordPress Function

The post() function is one of the most important functions in WordPress. It is used to display a post or page on a WordPress site. The post() function can be used in a number of ways, but the most common use is to simply call it with the ID of the post or page you want to display.

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

Top ↑

Source

File: wp-includes/query.php

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


Top ↑

Changelog

Changelog
VersionDescription
1.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.