All top-level pages are using index.php as template

I had the same issue and your fix helped me a lot.

After I fixed the issue with your solution I figured out that I had used a permalink in one custom post type that caused the issue.

I used years / year and I think because wordpress uses something like this in its archive pages it broke the site.

Probably this helps you also.

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