Global $post value outside the loop

Yes, this is how it is supposed to work. The global $post variable is set quite early in the page load, at the wp hook. As you can see from the hook order, this is before the loop starts.

Basically the $post object exists independent from its actual content in the database, which you retrieve during the loop. It’s specifically meant to be accessible all the time during page generation.

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