• 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

    (@jshepard)

    Here is a link to my site. Check out the behavior for yourselves.

    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

    (@jshepard)

    Anybody? This is driving me nuts!

    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.

    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…

    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.