So I don’t think this is possible with Sage 9 Beta 3.
Moving styles.css to /resources
in beta 3 has had an adverse affect on the effectiveness of the WordPress function locate_template
which is also used by get_template_part
.
You can see that function here: https://developer.wordpress.org/reference/functions/locate_template/#source
On a singular theme level moving the style.css doesn’t really have any downsides as Sage 9 Beta 3 also has stylesheet filters in place in functions.php - when the stylesheet entry doesn’t find a template file it defaults to the template entry. All is good in the world.
However, on a child theme level the locate_template
function ceases to work as expected due to the constant STYLESHEETPATH
. This constant expects wordpress templating files to be in the same directory as itself for child themes to work and override templates as we’re used to. This is why get_stylesheet_directory_uri
and get_template_directory_uri
yield different results when used in child themes.
In a child theme when STYLESHEETPATH is filtered/changed it causes the theme to deactivate or miss template overwrites. This is because at child level the stylesheet location is used both for activation, and theme file location. When in a child and parent scenario the stylesheet entry must be the child theme’s stylesheet location, and the template entry must be the parent theme. To my knowledge it’s not possible to have your pie and eat it because of this.
The only solutions I can see for this issue are:
- Manually
require_once
the parent functions file after load and drop WordPress default parent / child relationship - Most plugins, frameworks (WooCommerce etc) and themes depend on this ordering quite religiously so I don’t see this as feasible - Move styles.css and functions.php back to the root of the theme like in beta 2 and adjust the template directory filter when it is a child
- Move styles.css and functions.php into the views folder or a templates folder to make finding a solution easier
- Request a patch in WordPress core for the loading order of these files (Stupid to event think that’d be accepted)
- Do some trickery with Laravel / Blade - a wrapper for locate template perhaps
Of course I could be completely wrong and the roots team may already have their eye on a fix