Just wonder what is the difference between the "Main Index Template" index.php
and HomePage front-page.php
.
It seems that front-page.php
is displayed when visiting https://www.example.com/
, but index.php
seems also to be served for such a purpose.
If index.php
is not used when visiting https://www.example.com
, when it will be used?
-
1Have you referred to the template hierarchy? developer.wordpress.org/themes/basics/template-hierarchy– Jacob PeattieCommented Oct 4, 2021 at 8:12
-
@JacobPeattie, I read the document. If I understand correct, index.php works more like a fallback template, if for all cases, there are other templates available, then it will never be used?– alanccCommented Oct 4, 2021 at 8:45
-
@alancc you just answered your own question in a comment. front-page.php will be served first, if it does not exist (nor any others in the chain), index.php will be served as fallback. And yes, if front-page.php exists, index.php will not be served.– LovorCommented Oct 4, 2021 at 9:00
-
1@alancc Feel free to answer your own question here, so future visitors will see it better– keroCommented Oct 4, 2021 at 9:10
-
1@alancc It's usually not necessary to have every other template, so you'll usually have something that's using index.php. I believe it's also a requirement of themes on wordpress.org.– Jacob PeattieCommented Oct 4, 2021 at 9:14
|
Show 2 more comments