Use custom layout for certain templates

I am using roots and am trying to decide if I am using the custom base functionality properly.

I have a base-front-page.php for the home page and then for all the subpages I have modified the base.php file to handle all of the sub-pages layout.

Then for any custom templates (which have different API calls in each) I am creating files in the templates folder and naming them: content-newfilename.php. These all show up as expected in Wordpress when creating a new page in the template drop down.

What I am looking to do is have all of these custom templates inherit a layout that is different than the layout in base.php.

I have read the Theme Wrapper and Roots 101 multiple times, but just can’t seem to grasp how to best accomplish this.

Any help would be great!


If you’re using a custom page template like page-custom.php and calling content-custom.php then you can simply create base-page-custom.php and your new base will take effect.

So I have created a base-newsroom.php file - this brings in a left and right sidebar, and then the main content.

I have a page-newsroom.php in the same folder as the base file, which has the following code:

<?php get_template_part('templates/page', 'header'); ?> <?php get_template_part('templates/content', 'newsroom'); ?>

I also have a file in the templates folder named content-newsroom.php. I am getting the proper content from this file, but for whatever reason I am still seeing the base.php instead of base-newsroom.php - (I tested this by removing the code from the base-newsroom.php that brings in the right sidebar, but the right sidebar is still showing up, which means it is ignoring my custom base file and using the base.php).

What am I missing?


Got it working.
For anyone looking later - I had to name my base file -
base-content-newsroom.php for it to work.

By just using base-content-newsroom.php I believe you run the risk of not including your page header. As in my example above, it’s best practices with Roots to include “page” in your base filename, so consider using a base template with the filename base-page-newsroom.php.