Support » Fixing WordPress » Error: ‘invalid argument’ instead of ‘wp_list_pages’

  • Hi,
    i updated to wp1.5 and found it great, expecially for ‘pages’ feature.
    Using (and abusing:) the feature I created a certain number of parent-page and corresponding children and later I modified the .htaccess (/%pages%/%postname%/) to have the following permalink structure:


    everything ok, BUT:

    I cut some of the children-page in several subpages (<!--nextpage-->) and after the modify in the .htaccess in every post of the numbered sequence instead of the

    <?php wp_list_pages('title_li= <h2>' . __('gli Autori') . '</h2>' ); ?>

    I get the error:

    Warning: Invalid argument supplied for foreach() in public_html/wpress/wp-includes/template-functions-post.php on line 368

    Say that I don’t understand it is still too far from truth.
    Thanks for help and sorry for my eng.

Viewing 10 replies - 1 through 10 (of 10 total)
  • check to see if this patch will fix it.

    thanks but no.
    my template-functions-post.php looks exactly like it -and doesn’t work.

    Interesting, I am having the same problem.

    On my site, I have a page called WRITING. It’s children are POETRY, SHORT STORY. Each of those, in turn, have their own children which are the pieces themselves.

    So I’m trying to write a simple menu that will be listed on the WRITING page. Like this:

      <?php wp_list_pages('sort_column=menu_order&child_of=9&title_li=POETRY'); ?>
      <?php wp_list_pages('sort_column=menu_order&child_of=8&title_li=cuentos'); ?>

    Simple, right? Well I get the same line 368 error. BUT, if I add this (from the Codex examples page) above the other two wp_list_pages:

      <?php wp_list_pages('sort_column=menu_order'); ?>

    All three calls work perfectly! No error! Now this strikes me as very wierd. Ideas?

    I too am experiencing some oddities with the wp_list_pages function resulting in a line 368 error.

    I’m calling the wp_list_pages function from a static page, and there it works beautifully. But in the sidebar call for that page I then get the line 368 related error.

    If I click to another page, the sidebar call resovles itself, but if click back to the page where the additional wp_list_pages function is called, it burps again.

    code in page see result image

    < ?php
    global $id;
    $pagesArguments = “child_of=”.$id.”&title_li=”;
    //echo $pagesArguments;

    code in sidebar: see result image

    &lt?php wp_list_pages(); ?>

    I’m not sure I understand why the two seperate calls would affect one another. And there is certainly other code being successfully executed between the two.

    I tried adding to the page the one line as mentioned in the comment above:

    <?php wp_list_pages(‘sort_column=menu_order’); ?>

    and then that call, and the call I make in the page, and the call in the sidebar then all work. But of course that first call displays *all* pages, and that’s not what I want.

    I tried then removing that line again, and adding in the sort_column argument to just the page call, the page call & the sidebar, and then just the sidebar call, and all had the same results as shown in the images above. {sigh}

    Hmm, looking at some of the other posts (i.e., it looks like maybe the $r values need to be reset between calls made on the same page as different people are getting the same types of error when explicitly setting one or more of the arguments … searching more …

    Ahhhh … following info in I went into the template-functions-post.php file’s get_pages() function and commented out the …

    if (!isset($cache_pages) || empty($cache_pages)) {

    … line, and it’s closing bracket, and uploaded the file. Works great! I do have empty categories (something that post menthioned the cache check might be gaurding against) and thus far am having no issues. Will keep an eye out, but hope all this helps someone else too. :0}`


    @ puckrat,

    THANKS SO MUCH!!! It was the answer to my problems, too.


    I am unfamiliar with that permalink structure. I do not think %pages% is an allowed element.

    At any rate, <!--nextpage--> does NOT create SubPages. All it does is split up a post over several pages, and allows you to put little numbered links to those split-up pages as the bottom of the post with the following Template Tag:

    To create SubPages, just create a normal Page and adjust it’s Page Parent setting appropriately. See: and the rest of that article.

    EDIT: I’m making a distinction between pages and Pages as described:

    Oh wonderful! This worked fer me too! Thanks, thanks, thanks.

    I just applied the same ‘comment out the if-statement’ fix and it worked, but then found this: which in turn links to: which has links to two replacement files that truly fix the problem and not just a hack.

    The files are:

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Error: ‘invalid argument’ instead of ‘wp_list_pages’’ is closed to new replies.