Title: Warning: in_array() [function.in-array]: Wrong datatype for second argument
Last modified: August 20, 2016

---

# Warning: in_array() [function.in-array]: Wrong datatype for second argument

 *  Resolved [leviticus](https://wordpress.org/support/users/leviticus/)
 * (@leviticus)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/warning-in_array-functionin-array-wrong-datatype-for-second-argument/)
 * Just upgraded WordPress to 3.5 and now receiving the following warning on my 
   site:
 * `Warning: in_array() [function.in-array]: Wrong datatype for second argument .../
   public_html/wp-content/plugins/widget-logic/widget_logic.php(270) : eval()'d 
   code on line 1`
 * Will a fix/update to the plugin be coming soon to resolve the error? Or is there
   something I can do on this end?
 * [http://wordpress.org/extend/plugins/widget-logic/](http://wordpress.org/extend/plugins/widget-logic/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/warning-in_array-functionin-array-wrong-datatype-for-second-argument/#post-3293697)
 * the error suggests the problem is in one of the bits of widget logic in one of
   your widgets. (line 270 is the bit that executes your given WL code)
 * But you could try the DEV version which I have updated to work with 3.5
 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/warning-in_array-functionin-array-wrong-datatype-for-second-argument/#post-3293702)
 * never mind, I’ve committed 0.54 now. but you still may need to comb through your
   WL
 *  Thread Starter [leviticus](https://wordpress.org/support/users/leviticus/)
 * (@leviticus)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/warning-in_array-functionin-array-wrong-datatype-for-second-argument/#post-3293724)
 * Thanks for your quick reply alanft. I upgraded to 0.55 and still had the error,
   so I went through my WL and I think it was having trouble with the way I was 
   trying to get ancestors of a page:
    `global $post; return ( is_page('community')
   || $post->post_parent == '15' || in_array( 15, get_post_ancestors($post)) );`
   I changed it to a is_tree function found here [http://wordpress.org/support/topic/is_tree-function](http://wordpress.org/support/topic/is_tree-function)
   but that created a different error: ‘Warning: Invalid argument supplied for foreach()
   in …/wp-content/themes/rutland-theme/functions.php on line 26’ which is ‘foreach(
   $anc as $ancestor) {‘ Do you know the best WL to show a widget on children and
   grandchildren of a specific page ID?
 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/warning-in_array-functionin-array-wrong-datatype-for-second-argument/#post-3293730)
 * there’s another thread with someone having trouble with get_post_ancestors – 
   I’ll have a look at that to see if there’s some substantial change in WP3.5
 * hard to say what’s up with your is_tree function (as that page doesn’t have any
   code with foreach in it)
 * i will take a look at get_post_ancestors
 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/warning-in_array-functionin-array-wrong-datatype-for-second-argument/#post-3293731)
 * Yep, looking at 3.4 v 3.5, get_post_ancestors was re-written and now can return
   FALSE, so any
 * in_array(n, get_post_ancestors($post))
 * conditionals have to be written with a bit more caution testing $post first, 
   something like
 * ($post) && in_array(n, get_post_ancestors($post))

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Warning: in_array() [function.in-array]: Wrong datatype for second argument’
is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/widget-logic_c8dde5.svg)
 * [Widget Logic](https://wordpress.org/plugins/widget-logic/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/widget-logic/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/widget-logic/)
 * [Active Topics](https://wordpress.org/support/plugin/widget-logic/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/widget-logic/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/widget-logic/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [alanft](https://wordpress.org/support/users/alanft/)
 * Last activity: [13 years, 5 months ago](https://wordpress.org/support/topic/warning-in_array-functionin-array-wrong-datatype-for-second-argument/#post-3293731)
 * Status: resolved