have_posts()

You are here:

have_posts()

Determines whether current WordPress query has posts to loop over.

Return Return

(bool) True if posts are available, false if end of the loop.


Top ↑

More Information More Information

This function checks whether there are more posts available in the main WP_Query object to loop over. It calls have_posts() method on the global $wp_query object.

If there are no more posts in the loop, it will trigger the loop_end action and then call call rewind_posts() method.


Top ↑

Source Source

File: wp-includes/query.php

927
928
929
930
function have_posts() {
    global $wp_query;
    return $wp_query->have_posts();
}


Top ↑

Changelog Changelog

Changelog
Version Description
1.5.0 Introduced.
Was this article helpful?
Dislike 0
Views: 10