小编the*_*ann的帖子

为什么我不能在 WordPress functions.php 中加入多个 Google 字体?

我正在使用这个 Google 字体文件wp_enqueue_style排队。这是我的代码:

wp_enqueue_style( 'google-fonts', 'https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,300;0,400;0,700;1,400&family=Neuton:ital,wght@0,300;0,400;0,700;1,400&display=swap', [] );

这是在我的functions.php 文件中。

但是,当我在加载的页面上查看源代码时,该字体文件的 URL 被缩减为:https : //fonts.googleapis.com/css2?family=Neuton%3Aital%2Cwght%400%2C300%3B0%2C400% 3B0%2C700%3B1%2C400 &display=swap&ver=5.3.2

可以看到,第一个family参数在通过wp_enqueue_style. 有没有办法在不做任何黑客行为的情况下解决这个问题?我认为可能有一种过时的方法来为两种字体系列构建 URL,但我宁愿能够使用 Google 现在提供的内容。我里面的原始网址wp_enqueue_style是 Google Fonts 生成的供我嵌入的网址。

css php wordpress fonts google-fonts

15
推荐指数
2
解决办法
2417
查看次数

标签 统计

css ×1

fonts ×1

google-fonts ×1

php ×1

wordpress ×1