Php Wordpress-谷歌字体无法正常工作/导入
我是Wordpress的新手,我正在使用HTML5空白主题导入我的样式表。我注意到谷歌字体不适用于wordpress网站 我的header.php文件中有此链接-Php Wordpress-谷歌字体无法正常工作/导入,php,css,wordpress,html,Php,Css,Wordpress,Html,我是Wordpress的新手,我正在使用HTML5空白主题导入我的样式表。我注意到谷歌字体不适用于wordpress网站 我的header.php文件中有此链接- <link href='https://fonts.googleapis.com/css?family=Merriweather+Sans:100,200,400,700,700i,800,800i' rel='stylesheet' type='text/css' /> “身体”规则在Wordpress中的应用方式是否
<link href='https://fonts.googleapis.com/css?family=Merriweather+Sans:100,200,400,700,700i,800,800i' rel='stylesheet' type='text/css' />
“身体”规则在Wordpress中的应用方式是否与在前端情况下相同?或者我还需要添加/更改其他内容吗?您是在告诉wp加载stlye.css文件吗 尝试对functions.php文件执行此操作:
function load_styles() {
wp_enqueue_style('styles', 'path/to/style.css');
}
然后是(如果您的样式是针对站点的前端):
或者(如果您的样式用于站点的管理面板):
此外,您还通过以下操作添加了两次字体:
<link href='https://fonts.googleapis.com/css?family=Merriweather+Sans:100,200,400,700,700i,800,800i' rel='stylesheet' type='text/css' />
在您的style.css中
选择其中一个,或者您可以将其添加到functions.php文件中的“load_styles()”函数中:
add_action('wp_enqueue_scripts', 'load_styles');
add_action('admin_enqueue_scripts', 'load_styles');
function load_styles() {
wp_enqueue_style('styles', 'path/to/style.css');
wp_enqueue_style('fonts', 'https://fonts.googleapis.com/css?family=Merriweather+Sans:100,200,400,700,700i,800,800i');
}
如果这不起作用,请提供更多信息,例如:
- 浏览器的开发人员控制台上是否有错误
- css规则是否显示在开发人员控制台中
- 正在加载字体吗
@import url('https://fonts.googleapis.com/css?family=Merriweather+Sans:100,200,400,700,700i,800,800i');
function load_styles() {
wp_enqueue_style('styles', 'path/to/style.css');
wp_enqueue_style('fonts', 'https://fonts.googleapis.com/css?family=Merriweather+Sans:100,200,400,700,700i,800,800i');
}