Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prototype: Add custom templates #124

Closed
wants to merge 2 commits into from
Closed

Conversation

scruffian
Copy link
Contributor

@scruffian scruffian commented Oct 10, 2022

This is a prototype of how plugins might want to add custom templates to a theme without needing to modify the theme itself.

This works by attaching to two filters: get_block_template and get_block_templates. The new custom template is added programatically to the theme using these filters.

This approach could be used by plugins who require themes to have specific templates in order to function, without having to actually add the files to the theme.

One problem with this approach is that it makes some assumptions about the base template of the theme.

$title = 'template-title';
$description = 'description';
$custom_content = '<!-- wp:woocommerce/legacy-template {"template":"single-product"} /-->';
$index_template = wp_get_theme()->get_file_path( '/templates/index.html' );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes a block theme

@pbking
Copy link
Contributor

pbking commented Apr 29, 2024

Interesting experiment, but no longer relevant to the project. Closing as "interesting".

@pbking pbking closed this Apr 29, 2024
@vcanales vcanales deleted the add/custom-templates branch May 23, 2024 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants