Support » Fixing WordPress » Trouble with switch_to_blog() and wp_list_pages()

  • OK so I have a network website and built a custom site-map at

    For each branch in the sitemap, I execute the following code:


    before I upgraded to WordPress 3.5. It worked normally. After the upgrade I get the following error for each post that should appear in the list:

    Warning: in_array() []: Wrong datatype for second argument in …/wp-includes/post-template.php on line 1039

    So if there should be 10 posts in the list, the warning shows 10 times and then, the list is displayed normally.

    I have already disabled ALL of my plugins and they are not causing the problem.

    Can anyone help resolve this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • I am having the same problem with a network site after the client updated to 3.5; update to 3.5.1 had no effect. I have a temporary hack that might work for you, too:

    On line 1039 of post-template.php, I replaced the function in_array with isset and the problem has disappeared.

    Altering core files is a no-no, but I’m desperate. If you get this message, please let me know how it works for you, and I’ll report the problem to the dev team.

    Well, in my desperation, I failed to look at what that line is doing. Just comment the whole line out; all the line does is to insert a css class. If your formatting depends on the “current_page_ancestor” css class, you may have problems, but otherwise, you should be ok.

    This is getting old. here is the best idea yet. Replace the line with:

    if ( is_array ($_current_page->ancestors) && in_array ( $page->ID, $_current_page->ancestors ) )

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Trouble with switch_to_blog() and wp_list_pages()’ is closed to new replies.