How to use get_posts() function in functions.php

There should be a global declaration of $post at the beginning of the function. Just like this:

function get_my_posts(){
    global $post;
    // rest of the code.
}

Original answer from stackoverflow: xphan

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