Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aslamatwebdevstudios/58990b3fb5c35ae29d8edfedb221bad8 to your computer and use it in GitHub Desktop.
Save aslamatwebdevstudios/58990b3fb5c35ae29d8edfedb221bad8 to your computer and use it in GitHub Desktop.
Block specific custom styles
<?php
function my_theme_register_button_styles() {
wp_register_style(
'my-theme-button-styles',
get_stylesheet_directory_uri() . '/button-styles.css',
array(),
filemtime( get_stylesheet_directory() . '/button-styles.css' )
);
register_block_style(
'core/button',
array(
'name' => 'my-theme-button-style',
'label' => __( 'My Button Style', 'my_theme' ),
'style_handle' => 'my-theme-button-styles',
'style' => 'my-theme-button-style',
)
);
}
add_action( 'init', 'my_theme_register_button_styles' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment