Coding home page directly into index.php

4 replies
  • WEB DESIGN
  • |
I'm not sure if this is the right place to ask this.

I'm designing a wordpress website using a responsive theme framework.

I want the landing page (mydomain.com) to be different from the other pages on the site. (There is no blog, so no posts)

Currently I'm doing this by coding the landing page and its content directly into the index.php template.

Then I've designed the rest of the site using page.php with the content being added via "pages" in the Wordpress dashboard.

It works, but I'm not sure that it is good practice.

Does anyone have an opinion or feedback please? Or maybe a better way of achieving my goal.
#coding #directly #home #indexphp #page
  • Profile picture of the author Istvan Horvath
    No, it is NOT good practice. Here is why: the index.php file is the general "fall back" template for every missing template file in a theme!
    See more: Template Hierarchy « WordPress Codex

    Based on your summary description I'd go for the home.php template file if I need to hardcode stuff into it.
    Signature

    {{ DiscussionBoard.errors[7304268].message }}
    • Profile picture of the author rosetrees
      Hi Istvan
      I just came back to post saying I'd worked out that it needs to go in front-page.php

      I've left index.php blank

      Thanks for posting - nice to see you around. You've been missing from the main forum.

      You've got me wondering now. Should it be home.php or front-page.php. I need to do a bit more reading I think.
      {{ DiscussionBoard.errors[7304389].message }}
  • Profile picture of the author Istvan Horvath
    Yep, front-page.php would work as well. I didn't mention it because:
    a) it's a newer development
    b) wanted to keep it simple
    c) when giving more options people get confused :p

    By "blank" index you mean unchanged? or empty, no code? It shouldn't be the latter... see the reasons in my previous post.
    Signature

    {{ DiscussionBoard.errors[7304407].message }}
  • Profile picture of the author rosetrees
    Yes, at the moment index.php is completely blank. I'll replace it with the original, default code. Thanks for that and yes, I'm easily confused!
    {{ DiscussionBoard.errors[7304515].message }}

Trending Topics