Make WordPress Core

Changeset 2716


Ignore:
Timestamp:
07/17/2005 04:58:13 PM (20 years ago)
Author:
ryan
Message:

in_the_loop() Props: Mark Jaquith fixes #1518

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/classes.php

    r2635 r2716  
    1010    var $post_count = 0;
    1111    var $current_post = -1;
     12    var $in_the_loop = false;
    1213    var $post;
    1314
     
    5657        $this->post_count = 0;
    5758        $this->current_post = -1;
     59        $this->in_the_loop = false;
    5860    }
    5961
     
    594596    function the_post() {
    595597        global $post;
     598        $this->in_the_loop = true;
    596599        $post = $this->next_post();
    597600        setup_postdata($post);
     
    601604        if ($this->current_post + 1 < $this->post_count) {
    602605            return true;
    603         }
    604 
     606        } elseif ($this->current_post + 1 == $this->post_count) {
     607            // Do some cleaning up after the loop
     608            $this->rewind_posts();
     609        }
     610
     611        $this->in_the_loop = false;
    605612        return false;
    606613    }
  • trunk/wp-includes/functions.php

    r2715 r2716  
    14141414}
    14151415
     1416function in_the_loop() {
     1417    global $wp_query;
     1418   
     1419    return $wp_query->in_the_loop;
     1420}
     1421
    14161422function get_query_var($var) {
    14171423  global $wp_query;
Note: See TracChangeset for help on using the changeset viewer.