index.php
is not the template for the homepage, it’s the fallback template. Right now every page you load is falling back to the catch all index.php
template, but your index.php
doesn’t have a main loop, and isn’t set up as the fallback catch all template. Instead it’s doing its own new query and displaying the results.
So no, you’re not being redirected to the homepage, rather, you’re displaying the homepage on every page. Move your homepage code into a homepage template, e.g. home.php
or a page template called home. index.php
should be the last resort fallback, with a generic main loop.
I recommend you take a look at the template hierarchy to see how WordPress decides which template to load, and what you can implement