• I’m running WP 2.0.3 and currently using the Qwilm theme.

    On a subpage (or child page), such as this one: https://freakapotimus.com/greatestsongs/2005

    I get this error for my categories list:

    Warning: Invalid argument supplied for foreach() in
    /home/.nassim/snooble/freakapotimus.com/wp-includes/template-functions-category.php
    on line 321

    This error shows up regardless of the theme I am using.

    I get this error for my recent posts (only when using the Qwilm theme):

    Warning: Invalid argument supplied for foreach() in
    /home/.nassim/snooble/freakapotimus.com/wp-content/themes/Qwilm/sidebar.php
    on line 43

    I’ve tried searching the forums here, but haven’t found exactly what I’m looking for. Not sure where to start on fixing it. Any and all help appreciated!

Viewing 5 replies - 1 through 5 (of 5 total)
  • You’re calling list_cats on a category that has no children.

    Foreach errors are best fixed by casting to array the supposed array:

    foreach ( $foo as $bar ) {

    Becomes:

    foreach ( (array) $foo as $bar ) {

    Thread Starter snooble

    (@snooble)

    Thanks for that! I’ve updated my code to foreach ( (array) $foo as $bar ), and although I no longer get an error, the categories and recent posts don’t show up at all. Will they not show up on subpages? If that’s the case, I could probably not show those items instead of having empty lists.

    Thread Starter snooble

    (@snooble)

    I still cannot get the links to appear on the subpages, or child pages. Even though I don’t get an error on subpages anymore, nothing appears under: Archives (links to monthly), Pages, and Recent Posts. Under Categories it says “No categories”.

    Just a thought… what happens if you change the slug of that subpage to something else?

    Thread Starter snooble

    (@snooble)

    Hmm, I hadn’t thought of that, let’s try it and see…

    I changed the page slug from 2005 to countdown2005 and I still have the same results.

    freakapotimus.com/greatestsongs/countdown2005

    Thanks for the suggestion! I need to start trying some things I hadn’t thought of yet.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘foreach() errors on subpages only’ is closed to new replies.