WordPress.org

Ready to get started?Download WordPress

Forums

Warning: Invalid argument supplied for foreach() in /wp-includes/canonical.php (5 posts)

  1. nicolargo
    Member
    Posted 3 years ago #

    Hi, i use the lastest alpha version of WordPress (3.1 build 15672).

    When i try to access to my categories or tags pages (exemple: http://blog.nicolargo.com/category/open-source), i have the following error:

    Warning: Invalid argument supplied for foreach() in /srv/d_bilbo/web/blog/wp-includes/canonical.php on line 153

    Any idea ?

  2. nicolargo
    Member
    Posted 3 years ago #

    If i change the canonical.php script by replacing this section line 53:

    foreach ( $wp_query->tax_query as $tax_query )
        $term_count += count( $tax_query['terms'] );

    by this code:

    if (is_tax()) {
       foreach ( $wp_query->tax_query as $tax_query )
         $term_count += count( $tax_query['terms'] );
    }

    The problem is solved...

  3. nicolargo
    Member
    Posted 3 years ago #

    Patch needed on WordPress ?

  4. nicolargo
    Member
    Posted 3 years ago #

    Mmhh, did not solve all the issue a better patch will be:

    replace:

    foreach ( $wp_query->tax_query as $tax_query )
        $term_count += count( $tax_query['terms'] );

    by:

    foreach ( (array) $wp_query->tax_query as $tax_query )
        $term_count += count( $tax_query['terms'] )

    It works now when i try todisplay my category:

    http://blog.nicolargo.com/category/open-source

    But when i try to get the feed for that category (http://blog.nicolargo.com/category/open-source/feed), i have the following error on the XML file:

    <b>Warning</b>: Invalid argument supplied for foreach() in <b>/srv/d_bilbo/web/blog/wp-includes/canonical.php</b> on line <b>153</b>

    ...

  5. kuchigi rukia
    Member
    Posted 3 years ago #

    thank you so muchhhh... nicolargo, you are very genius!

Topic Closed

This topic has been closed to new replies.

About this Topic