Opo*_*poe 1 php wordpress load webfonts
我下载了一些空白的wordpress主题文件,并开始用自己的php,html和css填充它们.我使用以下代码来加入google webfont:
function load_fonts() {
wp_register_style('googleFonts', 'http://fonts.googleapis.com/css?family=Tauri');
wp_enqueue_style( 'googleFonts');
}
add_action('wp_print_styles', 'load_fonts');
Run Code Online (Sandbox Code Playgroud)
但我想添加另一个webfont.我尝试了两件事:
1:使用','在wp_register_style中添加它
function load_fonts() {
wp_register_style('googleFonts', 'http://fonts.googleapis.com/css?family=Tauri','http://fonts.googleapis.com/css?family=Muli');
wp_enqueue_style( 'googleFonts');
}
add_action('wp_print_styles', 'load_fonts');
Run Code Online (Sandbox Code Playgroud)
2:重复:
function load_fonts2() {
wp_register_style('googleFonts2', 'http://fonts.googleapis.com/css?family=Muli');
wp_enqueue_style( 'googleFonts2');
}
add_action('wp_print_styles', 'load_fonts2');
Run Code Online (Sandbox Code Playgroud)
不幸的是,两种方式都不起作用 任何人都可以告诉我为什么上面的方法不起作用,以及如何添加多个webfonts.先感谢您!
wp_register_style('googleFonts', 'http://fonts.googleapis.com/css?family=Tauri|Muli');
Run Code Online (Sandbox Code Playgroud)
|从webfonts API请求多个系列时,请使用管道分隔符.
文档 - Cntrl + F.multiple