I need to do a query that retrieves posts from a single category, and from several tags (being all tags of the currently opened single post) and places this in a sidebar. I've found a large part of the code already here, and adapted it here and there (such as the addition of a custom field for thumbnails). There's only one problem: some posts have more than one tag in common with the currently opened single post, resulting in duplicate post results.
I've been trying different solutions (such as described here), but can't get it to work with my limited PHP knowledge. Can someone tell me what is missing from the code?
[Code moderated as per the Forum Rules. Please use the pastebin]
Thanks for your help!