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!
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.
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