 Hey there, and welcome to Learn WordPress. In this tutorial, you're going to learn about a new feature added to WordPress in version 6.1, the ability to include block template parts in your classic themes. In this video, we will cover an overview of block template parts, how to add block template part support, creating block template parts, and using block template parts in PHP. One of the benefits of WordPress block-based themes is the ability to edit any of the reusable template parts from the site editor. With block template parts, users can make changes to specific parts of the theme without affecting the rest of the site layout or design. One of the most common examples of this is the proudly powered by WordPress branding that appears in the footer of most WordPress themes. In classic themes, in order to edit this, you would need to open the footer.php file, enter the relevant section in the code, and either change or remove it. If you made a mistake, it could lead to an error on your website. However, switching a site to a block theme means users could also edit the template files, which might not be ideal. While it is possible to lock down templates if users only need to be able to edit specific template parts, it's a lot more work to implement. In the WordPress 6.1 release, it is now possible to create block-based template parts in your classic themes and allow users the same flexibility as if they were using a block theme. For the code samples used in this tutorial, visit the Make WordPress themes blog post titled Testing and Feedback for using block-based template parts in classic themes. To make use of this functionality, the first step is to enable block template parts support in your classic theme. In your existing theme, open the functions.php file and then use the add theme support function to enable block template parts. Be sure to hook this into the after setup theme action hook, which is the correct hook to use when enabling theme functionality. So let's start with the hook, after setup theme, and we'll create our own add block template part support callback. Then we'll create the callback function, and use add theme support block template parts. Once this is done, a new menu item for template parts will appear under the appearance menu in the WordPress dashboard. The next step is to create a directory in the theme directory called parts and create your block template parts. So inside 2021, create a folder called parts. To start with, use the example footer template part code from the original blog post. Scroll down, and there's an example footer template part here, and we'll use that to create a footer HTML template part and paste the block code. Once the file is created, you can refresh the templates part editor, and you will see the template part available in the list. WordPress automatically reads any .html files in the parts directory of a theme, and makes them available as template parts in the editor. Notice also that you can't add template parts from the editor. They have to be created as files in the theme. To use your template part in the theme, you include it in any of your classic theme files by using the block template part function. This function has one string variable, the file name of the template part without the HTML extension. So for your new footer .html template part, you could use the following code. Block template part and parse it in the string footer. To show how this works, here's the footer .php template from a classic theme. And this is what the footer looks like on the front end. By replacing everything in the site info container in the footer .php file with the block based footer template part, you will see how the footer changes on the front end. So in the footer template, here is the site info container. Take out this whole section here. So we'll replace this with the footer template part. So open a php tag, block template part and parse in the string and close the php tag. And if we stretch to the front end and refresh, we can see the footer has changed. It's mostly the same, but includes the layout and structure that's included from the new footer template part. For example, there is some padding. Once this hybrid theme is installed on a WordPress site, any user can edit the content of the footer without affecting the layout or design of the theme. For example, the user could replace the wording with their own content. So just for fun, we'll edit the footer and we'll say proudly powered by coffee and we'll just grab a link and pop that in there. Save it and then view the update on the front end. Proudly powered by coffee. You can create as many reusable parts as you want this way and simply add them as template parts to the parts directory. With block template parts enabled on your theme, the files will be automatically registered and available for users to edit from the templates parts list in the WordPress dashboard. Happy coding!