-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
What problem does this address?
It is currently impossible to specify which templates should be loaded inside classic themes.
There are two theme supports to enable block templates and template parts:
add_theme_support( 'block-template-parts' );
add_theme_support( 'block-templates' );A classic theme might implement a complex archive layout with many customization features but still want to allow the possibility to use a template for the archive based on a customizer setting.
I believe that this extends to block-based themes as well. If you want to define templates for CPTs (e.g., WooCommerce Single Product), these will be loaded automatically, regardless of the plugin’s state. When it comes to classic themes, authors would probably want to allow the user to pick which templates he intends to override with block templates.
I’ve seen that WooCommerce has managed to load templates from the plugin in a custom class, but that feels a bit cumbersome.
What is your proposed solution?
Allowing an arguments array with which templates to be loaded for both theme supports could be a good solution:
add_theme_support( 'block-templates',
array(
'index' => get_template_directory() . '/includes/fse-templates/index.html',
'front-page' => get_template_directory() . '/includes/fse-templates/front-page.html',
)
);