0

I'm very new to WordPress. I'm going through some tutorials in developing a theme. What I'm trying to grasp is creating a theme when the pages are a bit different. They all have the same theme but the layout is different for example on the home page and the rest of the pages.

For an example of a home page:

enter image description here

And for all the content pages the look is somewhat different:

enter image description here

I'm looking at the hierarchy and I see home.php and page.php, but I'm not 100% sure how they tie in.

Any advice or links to better understand how this works would be appreciated

1
  • there is something called Custom Template. You can create and assign them to Pages. When you have custom template created it will appear in dashboard while creating a new page. If you select the custom template then wordPress will use that template for that page instead of page.php Commented Jun 18, 2020 at 17:44

1 Answer 1

1

Sometimes the names can be misleading as home.php actually refers to the page that stores all of your blog posts.

In general, use either page-home.php or front-page.php for the home page and then page.php for the rest. Whenever you have a specific page with a different layout, you can create a new template that is styled specifically for that. Eg. page-contact for a contact page that doesn't follow the styles of other pages. The page-XXXXX.php is dependent on the slug of the page so that is how WordPress finds it.

3
  • Does that mean when I'm creating the home page I would use page-home.php/front-page.php and page.php for the other pages to design my theme? Meaning I wouldn't be creating my theme in index.php?
    – adviner
    Commented Jun 18, 2020 at 18:07
  • Index.php tends to be the fallback for anything that doesn't fit any other existing file in the hierachy. Your 'theme' is actually all of the files included within the folder you're working with. Index.php is just one of those files, along with page.php, search.php, single.php, etc.
    – Luke
    Commented Jun 18, 2020 at 18:26
  • Thanks for the information Luke. Much appreciated
    – adviner
    Commented Jun 18, 2020 at 19:33

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.