How to declare this function correctly?

Firstly I don’t see $args assigned anywhere.
Secondly before displaying in front-end, check if post is created with your values.

Little debugging like printing $new_post before insert might give you your issue.

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