WordPress.org

Ready to get started?Download WordPress

Forums

Error: 'invalid argument' instead of 'wp_list_pages' (11 posts)

  1. pippi
    Member
    Posted 9 years ago #

    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:

    mysite/name_of_the_page/name_of_the_post

    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.

  2. Tahongawaka
    Member
    Posted 9 years ago #

    check to see if this patch will fix it.
    http://trac.wordpress.org/changeset/2360

  3. pippi
    Member
    Posted 9 years ago #

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

  4. dirtyverbs
    Member
    Posted 9 years ago #

    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?

  5. puckrat
    Member
    Posted 9 years ago #

    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;
    wp_list_pages($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}

  6. puckrat
    Member
    Posted 9 years ago #

    Hmm, looking at some of the other posts (i.e. http://wordpress.org/support/topic.php?id=24024#post-142685), 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 ...

  7. puckrat
    Member
    Posted 9 years ago #

    Ahhhh ... following info in http://wordpress.org/support/topic.php?id=26896 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}`

    lines

  8. AuntiAlias
    Member
    Posted 9 years ago #

    @ puckrat,

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

  9. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

    pippi:

    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:
    http://codex.wordpress.org/Template_Tags/wp_link_pages

    To create SubPages, just create a normal Page and adjust it's Page Parent setting appropriately. See: http://codex.wordpress.org/Pages#Pages_can_be_Subpages and the rest of that article.

    EDIT: I'm making a distinction between pages and Pages as described: http://codex.wordpress.org/Pages

  10. fyr
    Member
    Posted 9 years ago #

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

  11. gpaulson
    Member
    Posted 9 years ago #

    I just applied the same 'comment out the if-statement' fix and it worked, but then found this: http://mosquito.wordpress.org/view.php?id=934 which in turn links to: http://trac.wordpress.org/changeset/2421 which has links to two replacement files that truly fix the problem and not just a hack.

    The files are:
    trunk/wp-includes/template-functions-post.php
    trunk/wp-includes/functions.php

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.