When you do the following in your code $posttags = get_the_tags($item->term_id);
, $item
is referring to a post object, not a term object. Therefore, term_id
is an invalid property. This should be throwing a PHP notice.
While not certain, I think what you are intending to do is:
$posttags = get_the_tags($item->ID);
since get_the_tags
takes a post ID, not a term ID.