How to determine top level template file in functions.php? [duplicate]

You can check for the single page by using is_single() function.
https://developer.wordpress.org/reference/functions/is_single/

As for index page, I am not 100% sure but is_home() may be the one.
https://codex.wordpress.org/Function_Reference/is_home

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