mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
in_the_loop() Props: Mark Jaquith fixes #1518
git-svn-id: http://svn.automattic.com/wordpress/trunk@2716 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
253221dbb2
commit
0282a8fc0c
@ -9,6 +9,7 @@ class WP_Query {
|
|||||||
var $posts;
|
var $posts;
|
||||||
var $post_count = 0;
|
var $post_count = 0;
|
||||||
var $current_post = -1;
|
var $current_post = -1;
|
||||||
|
var $in_the_loop = false;
|
||||||
var $post;
|
var $post;
|
||||||
|
|
||||||
var $is_single = false;
|
var $is_single = false;
|
||||||
@ -55,6 +56,7 @@ class WP_Query {
|
|||||||
unset($this->queried_object_id);
|
unset($this->queried_object_id);
|
||||||
$this->post_count = 0;
|
$this->post_count = 0;
|
||||||
$this->current_post = -1;
|
$this->current_post = -1;
|
||||||
|
$this->in_the_loop = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reparse the query vars.
|
// Reparse the query vars.
|
||||||
@ -593,6 +595,7 @@ class WP_Query {
|
|||||||
|
|
||||||
function the_post() {
|
function the_post() {
|
||||||
global $post;
|
global $post;
|
||||||
|
$this->in_the_loop = true;
|
||||||
$post = $this->next_post();
|
$post = $this->next_post();
|
||||||
setup_postdata($post);
|
setup_postdata($post);
|
||||||
}
|
}
|
||||||
@ -600,8 +603,12 @@ class WP_Query {
|
|||||||
function have_posts() {
|
function have_posts() {
|
||||||
if ($this->current_post + 1 < $this->post_count) {
|
if ($this->current_post + 1 < $this->post_count) {
|
||||||
return true;
|
return true;
|
||||||
|
} elseif ($this->current_post + 1 == $this->post_count) {
|
||||||
|
// Do some cleaning up after the loop
|
||||||
|
$this->rewind_posts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->in_the_loop = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1413,6 +1413,12 @@ function is_paged () {
|
|||||||
return $wp_query->is_paged;
|
return $wp_query->is_paged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function in_the_loop() {
|
||||||
|
global $wp_query;
|
||||||
|
|
||||||
|
return $wp_query->in_the_loop;
|
||||||
|
}
|
||||||
|
|
||||||
function get_query_var($var) {
|
function get_query_var($var) {
|
||||||
global $wp_query;
|
global $wp_query;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user