You can follow these step.
- Develop your custom template file, for example,
custom-template.php, with the desired structure.
- Ensure to include the necessary WordPress functions for header, footer, and content.
- In your theme folder, locate the
template-canvas.php file.
- Replace its content or rename it to keep a backup, and then paste the content of your custom template file.
- Edit your custom template to add the additional containers you need, wrapping the blocks within
<div class="wp-site-blocks"> or as per your requirements.
- Save the changes and update your theme files.
template-canvas.php is a core file in WordPress located in the wp-includes folder. I don’t want to modify any files outside of the theme, as it would impact future WordPress updates. I prefer making all changes within the theme files.
You can use a combination of theme files and filters to accomplish your purpose. Here’s an easier method:
– Create a Custom Template in Your Theme:
- In your theme folder, create a new file, e.g.,
custom-template.php.
- Customize this file with your desired structure, including additional containers around blocks.
–Use template_include Filter:
- Open your theme’s
functions.php file.
- Use the
template_include filter to conditionally load your custom template file instead of the default template-canvas.php. Here’s an example:
function custom_template_include($template) { // Check if it's the template-canvas.php being loaded if (is_page_template('template-canvas.php')) { // Use your custom template file $custom_template = locate_template('custom-template.php'); if ($custom_template != '') { return $custom_template; } } return $template; } add_filter('template_include', 'custom_template_include');
This filter checks if the current template being loaded is template-canvas.php and replaces it with your custom template if it exists in the theme.
- Save your changes and update your theme files.
Hope this will help you….