为什么 font-family 不能在我网站的所有页面上运行?
Why isn't font-family working on all pages on my Website?
我已经更改了我网站首页上的 font-family,但无法在我网站的所有其他页面上进行同步。例如,我已经比较了首页和商店之间 Chrome 中的检查编码,并没有发现任何差异。谁能帮我解决这个问题?
https://youmeitea.com <-- 此页面按预期工作,有问题的字体位于 header
的左上角
https://youmeitea.com/shop <-- 此页面未按预期工作,左上角的字体不是 Berkshire Swash 字体
感谢您的任何帮助或建议,我很乐意尝试让它正常工作!
I have compared the inspect coding in Chrome between the frontpage and the Shop, for example, and see no differences there
那是因为 font-family
CSS 规则确实存在。但是,该字体未显示,因为您只是将其嵌入首页。
也就是说,以下内容仅出现在首页:
<link rel="stylesheet" id="google-fonts-1-css" href="https://fonts.googleapis.com/css?family=Berkshire+Swash%3A100%2C100italic%2C200%2C200italic%2C300%2C300italic%2C400%2C400italic%2C500%2C500italic%2C600%2C600italic%2C700%2C700italic%2C800%2C800italic%2C900%2C900italic%7CSource+Serif+Pro%3A100%2C100italic%2C200%2C200italic%2C300%2C300italic%2C400%2C400italic%2C500%2C500italic%2C600%2C600italic%2C700%2C700italic%2C800%2C800italic%2C900%2C900italic&ver=5.4" type="text/css" media="all">
您必须修正将 Berkshire Swash 排队以应用于 所有 页面的方式。
或者,尝试通过 @import 在您的样式表中嵌入字体:
@import url('https://fonts.googleapis.com/css?family=Berkshire+Swash%3A100%2C100italic%2C200%2C200italic%2C300%2C300italic%2C400%2C400italic%2C500%2C500italic%2C600%2C600italic%2C700%2C700italic%2C800%2C800italic%2C900%2C900italic%7CSource+Serif+Pro%3A100%2C100italic%2C200%2C200italic%2C300%2C300italic%2C400%2C400italic%2C500%2C500italic%2C600%2C600italic%2C700%2C700italic%2C800%2C800italic%2C900%2C900italic&ver=5.4');
编辑: 您可以通过挂接到 wp_enqueue_scripts
从子主题中加入 Berkshire Swash(或任何其他字体),就像这样:
add_action( 'wp_enqueue_scripts', 'sean_enqueue_google_fonts' );
function sean_enqueue_google_fonts() {
wp_enqueue_style( 'google-fonts', 'https://fonts.googleapis.com/css?family=Berkshire+Swash%3A100%2C100italic%2C200%2C200italic%2C300%2C300italic%2C400%2C400italic%2C500%2C500italic%2C600%2C600italic%2C700%2C700italic%2C800%2C800italic%2C900%2C900italic%7CSource+Serif+Pro%3A100%2C100italic%2C200%2C200italic%2C300%2C300italic%2C400%2C400italic%2C500%2C500italic%2C600%2C600italic%2C700%2C700italic%2C800%2C800italic%2C900%2C900italic&ver=5.4', array() );
}
我已经更改了我网站首页上的 font-family,但无法在我网站的所有其他页面上进行同步。例如,我已经比较了首页和商店之间 Chrome 中的检查编码,并没有发现任何差异。谁能帮我解决这个问题?
https://youmeitea.com <-- 此页面按预期工作,有问题的字体位于 header
的左上角https://youmeitea.com/shop <-- 此页面未按预期工作,左上角的字体不是 Berkshire Swash 字体
感谢您的任何帮助或建议,我很乐意尝试让它正常工作!
I have compared the inspect coding in Chrome between the frontpage and the Shop, for example, and see no differences there
那是因为 font-family
CSS 规则确实存在。但是,该字体未显示,因为您只是将其嵌入首页。
也就是说,以下内容仅出现在首页:
<link rel="stylesheet" id="google-fonts-1-css" href="https://fonts.googleapis.com/css?family=Berkshire+Swash%3A100%2C100italic%2C200%2C200italic%2C300%2C300italic%2C400%2C400italic%2C500%2C500italic%2C600%2C600italic%2C700%2C700italic%2C800%2C800italic%2C900%2C900italic%7CSource+Serif+Pro%3A100%2C100italic%2C200%2C200italic%2C300%2C300italic%2C400%2C400italic%2C500%2C500italic%2C600%2C600italic%2C700%2C700italic%2C800%2C800italic%2C900%2C900italic&ver=5.4" type="text/css" media="all">
您必须修正将 Berkshire Swash 排队以应用于 所有 页面的方式。
或者,尝试通过 @import 在您的样式表中嵌入字体:
@import url('https://fonts.googleapis.com/css?family=Berkshire+Swash%3A100%2C100italic%2C200%2C200italic%2C300%2C300italic%2C400%2C400italic%2C500%2C500italic%2C600%2C600italic%2C700%2C700italic%2C800%2C800italic%2C900%2C900italic%7CSource+Serif+Pro%3A100%2C100italic%2C200%2C200italic%2C300%2C300italic%2C400%2C400italic%2C500%2C500italic%2C600%2C600italic%2C700%2C700italic%2C800%2C800italic%2C900%2C900italic&ver=5.4');
编辑: 您可以通过挂接到 wp_enqueue_scripts
从子主题中加入 Berkshire Swash(或任何其他字体),就像这样:
add_action( 'wp_enqueue_scripts', 'sean_enqueue_google_fonts' );
function sean_enqueue_google_fonts() {
wp_enqueue_style( 'google-fonts', 'https://fonts.googleapis.com/css?family=Berkshire+Swash%3A100%2C100italic%2C200%2C200italic%2C300%2C300italic%2C400%2C400italic%2C500%2C500italic%2C600%2C600italic%2C700%2C700italic%2C800%2C800italic%2C900%2C900italic%7CSource+Serif+Pro%3A100%2C100italic%2C200%2C200italic%2C300%2C300italic%2C400%2C400italic%2C500%2C500italic%2C600%2C600italic%2C700%2C700italic%2C800%2C800italic%2C900%2C900italic&ver=5.4', array() );
}