Home › Forums › Gutenberg › Gutenberg ACF Blocks – JS Not Working/Loading in Editor/Preview › Reply To: Gutenberg ACF Blocks – JS Not Working/Loading in Editor/Preview
I have the same code and it works for me. The js file appears in the footer (back-end/gutenberg and front-end). Maybe try this:
function my_init() {
wp_register_style( 'team', get_template_directory_uri() . '/dist/blocks/css/team.css', array(), filemtime( get_template_directory() . '/dist/blocks/css/team.css' ), 'all' );
wp_register_script( 'team', get_template_directory_uri() . '/dist/blocks/js/team.js', array( 'jquery', 'application' ), filemtime( get_template_directory() . '/dist/blocks/js/team.js' ), true );
}
add_action('init', 'my_init');
// acf_register_block_type:
'enqueue_assets' => function () {
wp_enqueue_style( 'team' );
wp_enqueue_script( 'team' );
},
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!
Our guide looks into WordPress custom fields and how they stack up against the possibilities of ACF.
— Advanced Custom Fields (@wp_acf) July 18, 2022
https://t.co/hk3yibkHyk
© 2022 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.