【发布时间】:2022-10-22 02:18:00
【问题描述】:
我正在尝试按照以下说明创建我的第一个 ACF 块。 https://www.advancedcustomfields.com/resources/blocks/
我在插件目录中创建了一个名为“testimonial”的目录,然后添加了一个文件“testimonial.php”,其中包含以下内容:
add_action( 'init', 'register_acf_blocks' );
function register_acf_blocks() {
register_block_type( __DIR__ . '/testimonial' );
}
我将插件目录更改为“/testimonial”
我还添加了一个 block.json 文件:
{
"name": "acf/testimonial",
"title": "Testimonial",
"description": "A custom testimonial block.",
"style": ["file:./testimonial.css"],
"category": "formatting",
"icon": "admin-comments",
"keywords": ["testimonial", "quote"],
"acf": {
"mode": "preview",
"renderTemplate": "testimonial-template.php"
},
"align": "full"
}
加上两个空文件“testimonial-template.php”和“testimonial.css”。
如果我在 WordPress 中显示插件列表,我的插件不会被列出。我期待看到它被列为“推荐”。
我正在运行 Wordpress 6.0.2 并安装了 ACF Pro。
我做错了什么?
【问题讨论】:
标签: wordpress advanced-custom-fields block wordpress-gutenberg