Unlock Hidden Power: 6 Little-Known Ways to Master Custom Block Styles in WordPress
Method 2: register block style in PHP and style it via theme.json
- Best for: Theme developers
- Where you would typically use it: In the theme.json file and in functions.php
- Version requirements: WordPress 6.6 or higher with
theme.json
v3
To add a custom block style using this method, you’ll need to register the style and add your stylings in the theme.json
file.
Register block style
In your functions.php
file, use the register_block_style()
function to set the two mandatory arguments (additional optional arguments are covered below):