mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://stackoverflow.com/questions/79234401/how-change-the-default-value-of-the-heading-block-in-gutenberg/79234830
14 lines
433 B
Text
14 lines
433 B
Text
function define_editor_heading_levels( $args, $block_type ) {
|
|
if ( 'core/heading' !== $block_type ) {
|
|
return $args;
|
|
}
|
|
|
|
// Change default heading level value to 3
|
|
$args['attributes']['level']['default'] = 3;
|
|
|
|
// Keep only H3 level 3 option
|
|
$args['attributes']['levelOptions']['default'] = [ 3 ];
|
|
|
|
return $args;
|
|
}
|
|
add_filter( 'register_block_type_args', 'define_editor_heading_levels', 10, 2 );
|