Iterate the post index in the loop.
Source
function the_post() {
global $wp_query;
if ( ! isset( $wp_query ) ) {
return;
}
$wp_query->the_post();
}
Changelog
Version | Description |
---|---|
1.5.0 | Introduced. |
Iterate the post index in the loop.
function the_post() {
global $wp_query;
if ( ! isset( $wp_query ) ) {
return;
}
$wp_query->the_post();
}
Version | Description |
---|---|
1.5.0 | Introduced. |
You must log in before being able to contribute a note or feedback.
Function the_post() checks whether the loop has started and then sets the current post by moving, each time, to the next post in the queue.
As per the documentation, the available functions to access the post within the loop are:
next_post_link()
– a link to the post published chronologically after the current postprevious_post_link()
– a link to the post published chronologically before the current postthe_category()
– the category or categories associated with the post or page being viewedthe_author()
– the author of the post or pagethe_content()
– the main content for a post or pagethe_excerpt()
– the first 55 words of a post’s main content followed by an ellipsis (…) or read more link that goes to the full post. You may also use the “Excerpt” field of a post to customize the length of a particular excerpt.the_ID()
– the ID for the post or pagethe_meta()
– the custom fields associated with the post or pagethe_shortlink()
– a link to the page or post using the url of the site and the ID of the post or pagethe_tags()
– the tag or tags associated with the postthe_title()
– the title of the post or pagethe_time()
– the time or date for the post or page. This can be customized using standard php date function formatting.including the following conditional tags:
is_home()
– Returns true if the current page is the homepageis_admin()
– Returns true if inside Administration Screen, false otherwiseis_single()
– Returns true if the page is currently displaying a single postis_page()
– Returns true if the page is currently displaying a single pageis_page_template()
– Can be used to determine if a page is using a specific template, for example:is_page_template('about-page.php')
is_category()
– Returns true if page or post has the specified category, for example:is_category('news')
is_tag()
– Returns true if a page or post has the specified tagis_author()
– Returns true if inside author’s archive pageis_search()
– Returns true if the current page is a search results pageis_404()
– Returns true if the current page does not existhas_excerpt()
– Returns true if the post or page has an excerpt