html - 字体不在 wordpress 网站上呈现
问题描述
我创建了一个纯 html 网站,其中包含一个用 WordPress 开发的博客部分。我使用“PostGrid”插件来显示类似网格的结构,并在 WordPress 中使用帖子部分,允许在该博客部分添加帖子。
在上面的图像中,字体被正确渲染,但不是在第二页。
在下面的 urlhttp://localhost/wordpress/home/
上,我有我所有的博客。在这个页面上,我最多可以添加六个帖子,如果我添加更多博客,那么它将被添加到下一页,因为 WordPress 提供了内置的分页支持。
我在上面的 URL 上添加的博客使用自定义字体是正确的,但是如果我添加更多帖子/博客,它会转到下一页,即 : http://localhost/wordpress/home/page/2/
,这里字体不会被渲染并在控制台中显示错误。
获取http://localhost/wordpress/home/page/fonts/Gilroy-Semibold.ttf net::ERR_ABORTED 404(未找到)。
我的字体路径对于帖子的主页和第 2 页是相同的,但在第 2 页上它没有呈现。
我已经尝试了所有解决方案,通过在控制台上添加 css,我也从 WordPress 的 Simple CSS 更改了 css,但它没有加载。
谁能帮我解决这个问题,我会分享代码。
我在 WordPress 中的简单 CSS 中使用下面的 CSS,这对于两个博客页面都是相同的。
@font-face {
font-family:gilroylight;
src: url("../fonts/Gilroy-Light.ttf");
}
@font-face {
font-family:gilroysemibold;
src: url("../fonts/Gilroy-Semibold.ttf");
}
@font-face {
font-family:keepcalm;
src: url("../fonts/KEEPCALM-MEDIUM_0.TTF");
}
解决方案
您有字体文件的路径问题,请在控制台窗口中检查。并在您的样式/css 中更改您的路径/url。
/* If css and fonts are in same folder*/
@font-face {
font-family: "CustomFont";
src: url('CustomFont.ttf');
}
/* If fonts is outside of your css folder*/
@font-face {
font-family: "CustomFont";
src: url('../CustomFont.ttf');
}
/* Absolute static path of fonts file*/
@font-face {
font-family: "CustomFont";
src: url('file:///C:/Users/Administrator/fonts/CustomFont.ttf');
}
/* Url path of fonts file*/
@font-face {
font-family: "CustomFont";
src: url('http://localhost/wordpress/Your-font-folder-path/CustomFont.ttf');
}
希望能帮助到你。
推荐阅读
- c++ - 想用 C++ 文件中的另一个词替换一个词
- swiftui - 如何使用滑动手势在图像滑块内实现导航链接?
- conv-neural-network - 将 MFCC 和梅尔谱图与 CNN 结合使用
- label - ESRI Js API 4.15:FeatureLayer 标签在所有功能上不可见
- python - Matplotlib FuncAnimation 分步动画函数
- c# - Asp.NET Core 基于声明的授权
- c++ - QChart 初始化导致异常违规
- google-cloud-platform - 将角色分配给 GCP 中的组导致资源层次结构中不存在角色
- c# - 使用消息中心从选项卡式页面到视图模型的数据
- kernel - 32位多任务任务段更新