WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Update Problems (5 posts)

  1. gabay611
    Member
    Posted 11 months ago #

    I recently updated my wordpress account to 3.6 and now there is a message on both my admin page and the actual website:

    Warning: Invalid argument supplied for foreach() in /home2/gabay611/public_html/wp-includes/post.php on line 3561

    Warning: Invalid argument supplied for foreach() in /home2/gabay611/public_html/wp-includes/post.php on line 3561

    What is this and how do I get rid of it?

    Thank you,

    Kiara Elmore

  2. esmi
    Forum Moderator
    Posted 11 months ago #

    Have you tried:

    - deactivating all plugins to see if this resolves the problem. If this works, re-activate the plugins one by one until you find the problematic plugin(s).

    - switching to the default theme to rule out any theme-specific problems.

    - resetting the plugins folder by FTP or PhpMyAdmin. Sometimes, an apparently inactive plugin can still cause problems.

    - re-uploading all files & folders - except the wp-content folder - from a fresh download of WordPress. Make sure that you delete the old copies of files & folder before uploading the new ones.

  3. anuragparihar
    Member
    Posted 11 months ago #

    I solved it by replacing the codes in the post.php file in wp-includes folder:

    Old:

    function get_page_uri($page) {
    $page = get_post( $page );

    $uri = $page->post_name;

    foreach ( $page->ancestors as $parent ) {
    $uri = get_post( $parent )->post_name . "/" . $uri;
    }

    return $uri;
    }

    New:

    function get_page_uri($page) {
    if ( ! is_object($page) )
    $page = get_post( $page );
    $uri = $page->post_name;
    /* Added (array) in the offending line below */
    foreach ( (array)$page->ancestors as $parent ) {
    $uri = get_post( $parent )->post_name . "/" . $uri;
    }

    return $uri;
    }

    This might work for you as well :)

  4. anuragparihar
    Member
    Posted 11 months ago #

  5. Mike van Lohuizen
    Member
    Posted 11 months ago #

    I'd advise against modifying WordPress core files. When you update next time your change will be lost.

    As the topic you link to showed: most people found that a plugin was causing this error.

    You would be better off (and more secure) to fix the real cause of the error.

Reply

You must log in to post.

About this Topic