WordPressブロックエディタに複数のカスタムスタイル見出しを登録する

最終更新日

function.phpに追加

// タイトルのカスタムクラス
function my_custom_multiple_block_styles() {
	// 見出しスタイル1
	register_block_style(
			'core/heading',
			array(
					'name'  => 'ttl1',
					'label' => '見出し1',
					'inline_style' => '.is-style-ttl1 {  font-size: 40px;  font-weight: 800;  line-height: 1;  text-align: center;  color: #000;  margin-bottom: 1em;}',
			)
	);

	// 見出しスタイル2
	register_block_style(
			'core/heading',
			array(
					'name'  => 'ttl2',
					'label' => '見出し2',
					'inline_style' => '.is-style-ttl2 {	border-color: setting.$br;	border-top: 5px solid setting.$br;	border-bottom: 1px dotted setting.$br;	padding: .5em 0;}',
			)
	);

}
add_action('init', 'my_custom_multiple_block_styles');