Title: Error message= &quot;Warning: in_array() expects parameter 2 to be array, null given&quot;
Last modified: August 20, 2016

---

# Error message= "Warning: in_array() expects parameter 2 to be array, null given"

 *  Resolved [andre77](https://wordpress.org/support/users/andre77/)
 * (@andre77)
 * [15 years ago](https://wordpress.org/support/topic/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.

Viewing 16 replies (of 16 total)

[←](https://wordpress.org/support/topic/error-message-warning-in_array-expects-parameter-2-to-be-array-null-given/?output_format=md)
[1](https://wordpress.org/support/topic/error-message-warning-in_array-expects-parameter-2-to-be-array-null-given/?output_format=md)
2

 *  Thread Starter [andre77](https://wordpress.org/support/users/andre77/)
 * (@andre77)
 * [14 years, 12 months ago](https://wordpress.org/support/topic/error-message-warning-in_array-expects-parameter-2-to-be-array-null-given/page/2/#post-2107870)
 * Hey David!
 * Sorry for the late reply, been away for some days. Using custom meta fields is
   an idea that I didnt think of. That could give the administrative users more 
   flexibility, but if such a high flexibility isn’t needed, then I guess it would
   also result in a slightly more administrative work – as every new sub page would
   need have to have a custom field assigned to it to display the appropriate sidebar.
 * But I guess the possibilities are quite many if you know all the ropes of WordPress/
   PHP.
 * But the initial question/problem has been solved – thanks to your good effort
   🙂
 * Kind regards,
 * André

Viewing 16 replies (of 16 total)

[←](https://wordpress.org/support/topic/error-message-warning-in_array-expects-parameter-2-to-be-array-null-given/?output_format=md)
[1](https://wordpress.org/support/topic/error-message-warning-in_array-expects-parameter-2-to-be-array-null-given/?output_format=md)
2

The topic ‘Error message= "Warning: in_array() expects parameter 2 to be array, 
null given"’ is closed to new replies.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 16 replies
 * 4 participants
 * Last reply from: [andre77](https://wordpress.org/support/users/andre77/)
 * Last activity: [14 years, 12 months ago](https://wordpress.org/support/topic/error-message-warning-in_array-expects-parameter-2-to-be-array-null-given/page/2/#post-2107870)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
