Error message= "Warning: in_array() expects parameter 2 to be array, null given"
-
WordPress generates the following message: “Warning: in_array() expects parameter 2 to be array, null given in C:\wamp\…\wp-content\themes\themename\sidebar.php on line 22” (line 22 being the first row in the code)
And here below you can see the code:
if (is_page(25) || in_array(“25”,$post->ancestors)){ ?>
<?php dynamic_sidebar( ‘sidebarmenu_welcome’ ); ?><?php } else { ?>
<?php dynamic_sidebar( ‘sidebarmenu_other’ ); ?>
<?php } ?>(this code checks if I am on a certain page, or if the current page is an ancestor of that specific page)
The webpage I am working on has both static pages, and a blog. The above code works fine on all static pages, but on the Blog page, this error message comes up. And then I have configured the: “Front Page” and “Blog Page” through the “reading settings” in the Admin Panel.
i.e. for some reason this code doesnt work when displaying “posts” instead of pages.
Can you help me correct this code? So it works when both pages and posts are displayed.
- The topic ‘Error message= "Warning: in_array() expects parameter 2 to be array, null given"’ is closed to new replies.