WordPress.org

Support

Support » Plugins and Hacks » Warning Error 161

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/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author alanft

    @alanft

    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

    Note to self to add this to the FAQ

    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!

    Plugin Author alanft

    @alanft

    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)));

    Hi Alan,

    It still doesn’t show anything using the coding you provided.

    Plugin Author alanft

    @alanft

    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.