Help with the template wrappers

I’m a bit lost about how to work with the template wrappers to achieve what I want. Basically, I created a static homepage, now I want to modify the look of it in a minor way (mostly to not show the page title). I copied base.php to base-home.php and I also created a content-home.php in the templates folder and tried to edit my new base page to do get_theme_part for pulling in the customized template I did, but it doesn’t seem to have worked. I’ve tried rereading the theme wrapper guide a few times, but I am not having a good time getting my head around it. Can someone please help me out here. I am very lost.

The wrapper always starts with the WordPress template hierarchy. So if you need a new front page, you start by creating front-page.php in the theme root (not home.php). This is the same as in any other WordPress theme.

You can then customise this template as much or as little as you need. If you only want to remove the page title, duplicate and rename the page template and delete the call to the page header.

You only need a new base file if the general page markup (i.e. the markup outside of front-page.php) needs changing. This is done by taking the template name and prepending base-. So in this example we would copy the default base file and create base-front-page.php. This is where we could add a new sidebar, a custom footer or an alternative header etc.

The template parts (which are in the templates folder) are not directly affected by the wrapper. So front-page.php won’t automatically load templates/content-front-page.php unless you tell it to.

4 Likes

If you create page-home.php you should see your changes, but check @Foxaii’s post because this may not be the structure you want.

In your structure, everything will work nicely if your page title is “Home”, but if that gets changed then Roots will no longer use the template you created. If you always want your Front Page to use a particular template, regardless of its title, ID, or slug, then consider using the front-page.php and base-font-page.php structure suggested by @Foxaii.

For more reading and a great basic explanation you might also check out this post: Development using Roots

1 Like