Where does php code to load data go?

Thing is, the code can go to many places. For me, personally, is to develop own plugin and add code there.

If you need to something execute at certain point, use add_action hook.

From what you wrote, this question might be helpful: add_action hook for completely new post?

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