Is it possible to change the get_posts() or wp_query() function to alter the results that are returned?

do you mean something like this?

https://developer.wordpress.org/reference/hooks/pre_get_posts/

Here you can alter the query before it is actually run.

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