Title: $do_not_duplicate array not working properly
Last modified: August 19, 2016

---

# $do_not_duplicate array not working properly

 *  [wmmead](https://wordpress.org/support/users/wmmead/)
 * (@wmmead)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/do_not_duplicate-array-not-working-properly/)
 * Hi, I am stumped on this one. I am working on a magazine style site with multiple
   loops displaying posts from various categories and I am using the $do_not_duplicate
   array to keep the same posts from displaying in other loops as per the Codex.
 * Now here is the kicker: It actually works, but I am getting an error on my error
   log that says:
 * PHP Warning: in_array() [[function.in-array](https://wordpress.org/support/topic/do_not_duplicate-array-not-working-properly/function.in-array?output_format=md)]:
   Wrong datatype for second argument in /home/alvinr/public_html/wp-content/themes/
   moonandback/sidebar.php on line 67
 * Line 67 is where I am checking the $do_not_duplicate array to make sure I continue
   over any posts that are duplicates. Now it is actually keeping the duplicates
   from showing but my error log is getting filled up with all these errors (one
   for each post in the loop).
 * What is even more weird, is that I can not get it to generate this error every
   time. It seems to only do it the first time I load the page. Perhaps some cacheing
   is going on so that it is not duplicating the error on subsequent loads.
 * Anyone have any ideas?

Viewing 1 replies (of 1 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/do_not_duplicate-array-not-working-properly/#post-1808031)
 * Is it possible that you do not initialize $do_not_duplicate as an empty array
   before adding in ids? If not, and there are no ids added, then it will not be
   an array and will cause the error. Try using this before you populate $do_not_duplicate:
 * `$do_not_duplicate = array();`

Viewing 1 replies (of 1 total)

The topic ‘$do_not_duplicate array not working properly’ is closed to new replies.

## Tags

 * [do_not_duplicate](https://wordpress.org/support/topic-tag/do_not_duplicate/)
 * [in_array](https://wordpress.org/support/topic-tag/in_array/)
 * [multiple loops](https://wordpress.org/support/topic-tag/multiple-loops/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [15 years, 6 months ago](https://wordpress.org/support/topic/do_not_duplicate-array-not-working-properly/#post-1808031)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
