Stylesheet specified in register_block_style is not enqueued on front-end
-
I am using this bit of code to register a custom button style, but it doesn’t seem to work on the front-end.
add_action('init', function() { wp_register_style( 'cms-button', get_template_directory_uri() . '/assets/css/button-custom.css', array(), filemtime( get_template_directory() . '/assets/css/button-custom.css' ) ); register_block_style('core/button', [ 'name' => 'custom', 'label' => __('Custom', 'cms'), 'style_handle' => 'cms-button' ]); });
In admin:
– The style option appears in admin UI
– Custom class is added to the markup
– CSS is enqueuedOn the front-end:
– Custom class is added to the markup
– CSS is NOT enqueued, neither as a separate stylesheet nor inlineIs this expected behavior? I was under the impression that the stylesheet will be enqueued for both whenever button block is used.
Any advice would be greatly appreciated.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Stylesheet specified in register_block_style is not enqueued on front-end’ is closed to new replies.