same get_posts function works diffrently in tag.php and functions.php

Some arguments for your query are with variables, we don’t know how you define them in the function. i.e : $posts_not_in can be the same or not. And will change your results. Same for $terms.

You maybe need to introduce an offset var and add it to each query.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)