Title: Broken pages implementation
Last modified: August 18, 2016

---

# Broken pages implementation

 *  [jshepard](https://wordpress.org/support/users/jshepard/)
 * (@jshepard)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/broken-pages-implementation/)
 * I had Pages working (seemingly) fine on my fresh 1.5 installation. However, when
   I created a multi-page post(with <!–nextpage–>), the wp_list_pages() function
   decided to vomit all over my site for no apparent reason. My call to the function
   is as follows:
    `<?php wp_list_pages('title_li='); ?>` The error it gave me was:`
   Warning: Invalid argument supplied for foreach() in /my/long/path/to/wp-includes/
   template-functions-post.php on line 369`
 * It is now 2AM, I have spent 3 hours trying to figure this out (I consider myself
   an adequate PHP programmer), but to no avail. I’m ready to pull my toenails off
   with a pair of rusty pliers.
 * Someone, please tell me why WP isn’t acting like it should. Yes, I know that 
   there is an issue with the array… the bigger question is WHY is there an issue
   with the array — and better yet, what can I do to fix it?

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

 *  Thread Starter [jshepard](https://wordpress.org/support/users/jshepard/)
 * (@jshepard)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/broken-pages-implementation/#post-157507)
 * Here is a link to my site. Check out the behavior for yourselves.
 * [http://cyberdynamic.net/](http://cyberdynamic.net/)
 * You’ll notice that the page links appear just fine on the home page (Code..etc..
   etc..Downloads at right). Now, click on the “Code” link. The page links disappear!?!
   Go back, and click on Computer Science. BZZZZT!!! ERROR!!!
 * What… the… heck… is… going… on… ??????
    I’m going to try to sleep on it and see
   if I have any ideas in the morning — but I’m still happily anticipating a revelation
   from one of you WP gurus =:o)
 *  Thread Starter [jshepard](https://wordpress.org/support/users/jshepard/)
 * (@jshepard)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/broken-pages-implementation/#post-157562)
 * Anybody? This is driving me nuts!
 *  [bcswebstudio](https://wordpress.org/support/users/bcswebstudio/)
 * (@bcswebstudio)
 * [20 years, 8 months ago](https://wordpress.org/support/topic/broken-pages-implementation/#post-158126)
 * jshepard- did you ever get it?
    My test wp installation works fine until I try
   to include subpages in the header.php template. Only slightly modified from the
   wp docs comments on wp_list_pages(), here is my offending code:
 * `
    <?php if (is_page()) { ?> <div id="subpagemenu"> <?php global $id; wp_list_pages('
   child_of=' . $id . '&title_li=<h2>Sub Pages</h2>'); ?> </div> <?php } ?>  I get:
   Warning: Invalid argument supplied for foreach() in /mypath/wp-includes/template-
   functions-post.php on line 378
 * Taking out that snippet for listing subpages remedies the noise.
 *  [bcswebstudio](https://wordpress.org/support/users/bcswebstudio/)
 * (@bcswebstudio)
 * [20 years, 8 months ago](https://wordpress.org/support/topic/broken-pages-implementation/#post-158127)
 * More info on the topic:
    By placing my sub-page iteration in page.php _before_
   the line: ` <?php if (have_posts()) : while (have_posts()) : the_post(); ?>  
   it breaks, but immediately _following_ the above line, it works. Something about
   that line seems to set $id for me…
 *  [bcswebstudio](https://wordpress.org/support/users/bcswebstudio/)
 * (@bcswebstudio)
 * [20 years, 8 months ago](https://wordpress.org/support/topic/broken-pages-implementation/#post-158128)
 * Solution!
    After reading the wp docs on The Loop to explain the above discovery,
   I came up with this: ` the_post(); rewind_posts();  which goes somewhere before
   the “global $id;” in my above-above code snippet. I don’t know how efficient 
   this is, but it works (for now?)

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

The topic ‘Broken pages implementation’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [bcswebstudio](https://wordpress.org/support/users/bcswebstudio/)
 * Last activity: [20 years, 8 months ago](https://wordpress.org/support/topic/broken-pages-implementation/#post-158128)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
