admin管理员组

文章数量:1295856

I've previously (succesfully) made gutenberg block in a plugin, and am now doing so for a theme. However, I'm getting daft errors.

I've created a block using npx @wordpress/create-block foldlayout

Then in functions.php I have include get_stylesheet_directory().'/blocks/foldlayout/foldlayout.php';

But my site seems to be requesting an odd file:

script src='http://localhost/wp-content/plugins/C:/laragon/www/wp-content/themes/fold/blocks/foldlayout/build/index.js?ver=0c1c542b672d462d63ad1563f59a52b4' id='create-block-foldlayout-editor-script-js'

Clearly this isn't right, but I can't work out how to sort it...

Info as requested:

Content of foldlayout.php:

function create_block_foldlayout_block_init() {
    register_block_type_from_metadata( __DIR__ );
}
add_action( 'init', 'create_block_foldlayout_block_init' );

which is referencing block.json:

{
    "apiVersion": 2,
    "name": "create-block/foldlayout",
    "title": "Foldlayout",
    "category": "theme",
    "icon": "smiley",
    "description": "Example block written with ESNext standard and JSX support – build step required.",
    "supports": {
        "html": false
    },
    "textdomain": "foldlayout",
    "editorScript": "file:/build/index.js",
    "editorStyle": "file:./build/index.css",
    "style": "file:./build/style-index.css"
}

本文标签: Error defining a gutenberg block in a theme