是否可以在Wordpress主题中包含自定义的Gutenberg块。这样我就不必上传两个单独的部分:主题和带有Gutenberg块的插件。
我已经尝试用主题内部的Gutenberg插件创建一个子文件夹, 并将其包含在主题的functions.php文件中。但这没有用。
#1
我发现你是新的贡献者;欢迎!
应该可以执行以下操作:将用于注册代码块的PHP放入主题的functions.php文件中。你必须编写一个与init操作挂钩的函数, 并执行以下操作:
- 使用wp_register_script()指定一个JavaScript文件, 该文件将用作你的块的模板;
- 使用register_block_type()注册你的块。
该模板文件将与JSX一起格式化, 该模板文件将与functions.php一起放在主题中或在子文件夹中。
当然, 你编写代码的细节取决于你希望块执行的操作。我强烈建议你阅读WordPress的官方Gutenberg Block Tutorial。
来源:
https://www.srcmini02.com/63575.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_41781.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57