post__in – Placing content from a foreach loop inside of an array

Looking at your code – $lastarray will not be an array of ID’s (as you might be expecting), but an array with a single element containing a string of comma separated IDs.

$output is already an array of the $attr[‘id’] – try commenting (add // to the start) to the lines starting with $testarray and $lastarray and replacing 'post__in' => $lastarray with 'post__in' => $output

See if that helps.

Edit: to clarify – post__in expects an array (rather than ‘id’,’id’,’id’ string) – see here

Jon

Leave a Comment