Support » Fixing WordPress » $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]: 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)
  • 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.