Title: Warning Error 161
Last modified: August 20, 2016

---

# Warning Error 161

 *  [JustBlog](https://wordpress.org/support/users/justblog/)
 * (@justblog)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/warning-error-161/)
 * I’m getting the following error when use this in widget logic:
    **global $post;
   return (in_array(38,get_post_ancestors($post)));**
 * **The error: Warning: in_array() [function.in-array]: Wrong datatype for second
   argument in /home/myhosting/public_html/wp-content/plugins/widget-logic/widget_logic.
   php(161) : eval()’d code on line 1**
 * Can someone please let me know what’s wrong?
 * Thanks!
 * [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, 4 months ago](https://wordpress.org/support/topic/warning-error-161/#post-3341081)
 * get_post_ancestors changed subtly in WP3.5
 * see the suggestions here
 * [http://wordpress.org/support/topic/upgrade-error-in_array-expects-parameter-2-to-be-array](http://wordpress.org/support/topic/upgrade-error-in_array-expects-parameter-2-to-be-array)
 * Note to self to add this to the FAQ
 *  Thread Starter [JustBlog](https://wordpress.org/support/users/justblog/)
 * (@justblog)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/warning-error-161/#post-3341119)
 * Hi Alan,
 * Thanks for reply but I don’t quite get what the code means.
 * I put in the following code and it appears in every pages.
 * global $post; if ( ($post) && !in_array(112,get_post_ancestors($post))) return
   true;
 * I only want it to appear in post 112 and its ancestors.
 * What should i do?
 * Thanks!
 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/warning-error-161/#post-3341126)
 * There are 2 problems I can see. One is the ! which is saying if $post is NOT 
   in the list of ancestors. The other is that you’ve left it open what’s returned
   when your ‘if’ is not true – perhaps the default is true, hence this statement
   could always return true.
 * Try
 * global $post; return ( ($post) && in_array(112,get_post_ancestors($post)));
 *  Thread Starter [JustBlog](https://wordpress.org/support/users/justblog/)
 * (@justblog)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/warning-error-161/#post-3341128)
 * Hi Alan,
 * It still doesn’t show anything using the coding you provided.
 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/warning-error-161/#post-3341137)
 * well i wasn’t convinced that the default return was true – i was grasping a bit
   there.
 * sorry, I don’t know what more the problem can be – you could try troubleshooting
   using a PHP widget that uses print_r to print out the array returned by get_post_ancestors
   which would help work out where things are going awry

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

The topic ‘Warning Error 161’ 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, 4 months ago](https://wordpress.org/support/topic/warning-error-161/#post-3341137)
 * Status: not resolved