预计阅读时间: 2 分钟

您可以通过将此过滤器添加到父主题(或子主题)的functions.php文件中,将自定义字体添加到WordPress定制器中的排版下拉列表中。


function tmu_custom_fonts( $standard_fonts ){

	$my_custom_fonts = array();

	$my_custom_fonts['kitten'] = array(
		'label' => 'kitten',
		'variants' => array('regular'),
		'stack' => 'kitten, sans-serif',
	);

	$my_custom_fonts['font2'] = array(
		'label' => 'Another Font',
		'variants' => array('regular','italic','700','700italic'),
		'stack' => 'anotherfont, sans-serif',
	);
	
	return array_merge_recursive( $my_custom_fonts, $standard_fonts );

}
add_filter( 'kirki/fonts/standard_fonts', 'tmu_custom_fonts', 20 );

label:在排版下拉列表中显示的名称
variants:要包含为数组的所有字体粗细
stack:css font-family属性

此文章对你有帮助吗? 已有 1 人说这篇文章是有用的。