Unlock Hidden Power: 6 Little-Known Ways to Master Custom Block Styles in WordPress
3b. Use the inline_style
parameter
- Best for: Plugin developers and theme developers
- Where you would typically use it: In the main plugin PHP file or
functions.php
- Version requirements: WordPress 5 or higher
The value for the inline_style
parameter is a combination of the CSS selector and the CSS properties.
function my_double_frame_styles() {
register_block_style(
'core/image',
array(
'name' => 'double-frame',
'label' => __( 'Double-Frame', 'pauli' ),
'inline_style' => '.wp-block-image.is-style-double-frame
img { border: 10px ridge lightgreen; }'
)
);
}
add_action( 'init', 'my_double_frame_styles' );