Home › Forums › Gutenberg › Block script error › Reply To: Block script error
Thanks for the reply @mnajlat.
I added product-grid.asset.php to the same directory as the block.json file with the following array:
return array(
'handle' => 'product-grid-script',
'dependencies' => array(''),
'version' => '1.0',
);
Then I added the following in the block.json file:
"script": "file:./product-grid.js",
This got rid of the error but product-grid.js doesn’t load. Do you see any issues with what I added?
I did find a work around by registering the script on init using:
wp_register_script( 'product-grid-script', get_template_directory_uri() . '/acf-blocks/products/product-grid/product-grid.js', array(), '1.0.0', true );
Then in block.json I call the script’s handle:
"script": "product-grid-script",
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We’re reaching out to our multilingual users to ask for help in translating ACF 6.1. Help make sure the latest features are available in your language here: https://t.co/TkEc2Exd6U
— Advanced Custom Fields (@wp_acf) May 22, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.