0

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?

7
  • 1
    Have you referred to the template hierarchy? developer.wordpress.org/themes/basics/template-hierarchy Commented 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?
    – alancc
    Commented 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.
    – Lovor
    Commented Oct 4, 2021 at 9:00
  • 1
    @alancc Feel free to answer your own question here, so future visitors will see it better
    – kero
    Commented 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. Commented Oct 4, 2021 at 9:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.