Title: Mike Glendinning's Replies | WordPress.org

---

# Mike Glendinning

  [  ](https://wordpress.org/support/users/mdgl/)

 *   [Profile](https://wordpress.org/support/users/mdgl/)
 *   [Topics Started](https://wordpress.org/support/users/mdgl/topics/)
 *   [Replies Created](https://wordpress.org/support/users/mdgl/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/mdgl/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/mdgl/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/mdgl/engagements/)
 *   [Favorites](https://wordpress.org/support/users/mdgl/favorites/)

 Search replies:

## Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Strange the_content() behavior on paginated posts is driving me insane!](https://wordpress.org/support/topic/strange-the_content-behavior-on-paginated-posts-is-driving-me-insane/)
 *  [Mike Glendinning](https://wordpress.org/support/users/mdgl/)
 * (@mdgl)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/strange-the_content-behavior-on-paginated-posts-is-driving-me-insane/#post-1214385)
 * [@safiayonker](https://wordpress.org/support/users/safiayonker/): in this case,
   the “&” is probably a typo.
 * I’m not a PHP expert, but this is supposed to be how you return a reference rather
   than a copy of a variable (see the [PHP manual](http://www.php.net/manual/en/language.references.return.php)
   for more information).
 * At least in WordPress 3.0 it seems that “get_posts” is not declared this way,
   but “get_children” is (see source file “wp-includes/post.php”), so you should
   probably use a “&” for the latter but not for the former.
 * In practice, I’m not sure how picky the PHP compiler/runtime is about this sort
   of thing, so you may be able to get away with or without the “&” in many situations.
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Strange the_content() behavior on paginated posts is driving me insane!](https://wordpress.org/support/topic/strange-the_content-behavior-on-paginated-posts-is-driving-me-insane/)
 *  [Mike Glendinning](https://wordpress.org/support/users/mdgl/)
 * (@mdgl)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/strange-the_content-behavior-on-paginated-posts-is-driving-me-insane/#post-1214371)
 * Hi,
 * I had a similar issue and believe the problem here is a bug within function “
   setup_postdata()” (found in query.php line 2710 for WP 2.9.1) and its handling
   of global variables.
 * This function sets the global variable “$page” based on the instance variables
   of the global query object, i.e. “$page = get_query_var(‘page’)”.
 * Of course if you have done a separate query (with “get_posts()” or whatever) 
   and are trying to make use of the template functions by calling “setup_postdata()”,
   this is incorrect as the value of “$page” should be related to your separate 
   query.
 * The problem is further compounded because “setup_postdata()” only overwrites 
   the first entry in the global “$pages[]” array if your separate query has only
   a single page. Hence, the other array entries still contain data from the main
   page and can be inadvertently accessed by function “get_the_content()” using 
   the incorrect value of “$page”.
 * My solution for handling nested loops in this way is as follows:
 *     ```
       $myposts = &get_posts(...) /* Or new WP_Query or whatever. */
       global $post, $page;
       $mysavedpost = $post;
       foreach ($myposts as $post) {
          setup_postdata($post); $page = 1;
   
          the_title(); the_content(); /* And so on. */
   
       }
       $post = $mysavedpost; setup_postdata($post);
       ```
   
 * But it would still be nice if the problems with “setup_postdata()” were fixed!

Viewing 2 replies - 1 through 2 (of 2 total)