admin管理员组

文章数量:1122832

I am looking for a way for users (who will be site admins) to design Blocks that will be used by a plugin I am developing. I want the solution to work in both Classic and Block themes, so I have been exploring the support for Template Part Blocks in Classic themes.

This is working, and when I go to Appearance / Template Parts, the existing Template Parts I have defined can be edited. However there is no option to add a new Template Part. It appears that the only way to add one is to put a .html file into the file system. Note that at present I am adding these files to my Theme folder, but I have found a solution that will allow them to be added to my Plugin folder, I just haven't implemented this yet.

Is there a way to allow users to create new Template Parts in Classic Themes without creating a file manually?

I have considered providing an option on one of my admin screens to create a new file for the Template Part, which the user could then update with the editor, but I am concerned that these files would be lost when the plugin is updated.

I am looking for a way for users (who will be site admins) to design Blocks that will be used by a plugin I am developing. I want the solution to work in both Classic and Block themes, so I have been exploring the support for Template Part Blocks in Classic themes.

This is working, and when I go to Appearance / Template Parts, the existing Template Parts I have defined can be edited. However there is no option to add a new Template Part. It appears that the only way to add one is to put a .html file into the file system. Note that at present I am adding these files to my Theme folder, but I have found a solution that will allow them to be added to my Plugin folder, I just haven't implemented this yet.

Is there a way to allow users to create new Template Parts in Classic Themes without creating a file manually?

I have considered providing an option on one of my admin screens to create a new file for the Template Part, which the user could then update with the editor, but I am concerned that these files would be lost when the plugin is updated.

Share Improve this question asked Jul 9, 2024 at 21:09 zcesl53zcesl53 354 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

According to Carolina's excellent reference on full site editing, hybrid themes (that use both PHP and block template parts) can only allow users to add new template parts if you activate the Gutenberg plugin.

本文标签: Adding new Template Parts in the Block Editor when using Classic Themes