Home › Forums › ACF PRO › ACF Blocks with block.json generates wrong CSS file URL in editor › Reply To: ACF Blocks with block.json generates wrong CSS file URL in editor
OK… well, no one here seems to have anything else to say about this, but just in case a future ACF PRO user encounters this same issue, I’ve found a workaround.
Using the "file:./whatever.css"
value still never works for me in the editor (though it’s fine on the front end), but I’ve discovered that registering the script/style first, then registering the block and using the handle in block.json
works.
So for example, wherever you’re registering the whatever
block, you’d have these lines:
wp_register_style('whatever-css', get_theme_file_uri('blocks/whatever/whatever.css'));
register_block_type(get_theme_file_path('blocks/whatever'));
And then in your whatever
block’s block.json
file, you’d have this:
"style": "whatever-css",
It works!
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 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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.