php - 使用子主题在 headers.php 中插入字体

标签 php html css wordpress

我第一次在 Wordpress 中使用子主题。 我想在 headers.php 中插入一种字体,但我想使用子主题来完成。 到目前为止,我的子主题上唯一的文件是 style.css。 如何在我的子主题中创建 headers.php 文件并插入此字体:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

最佳答案

您可以改用函数 wp_enqueue_style

创建一个文件并将其命名为functions.php

然后使用这段代码来包含它

You can replace "My_font" with anything you want, just be sure to avoid spaces, and be sure to replace it in the function "add_action" too.

function My_font() {
    wp_enqueue_style('font-awesome','https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css');
}
add_action('wp_enqueue_scripts','My_font');

关于php - 使用子主题在 headers.php 中插入字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34911791/

相关文章:

php - 使用 "insert"时图像上传,但使用 "update"时不上传

html - 使用 VSCode 创建完整的 html 页面并标记

javascript - 如何向 Draft js 编辑器添加可点击的填充

php - 仅当用户在 Laravel 5.7 中处于事件状态时才登录用户

php - 与数据库的连接太多,导致某些查询无法执行

html - 如何防止 Bootstrap 3 列重叠

html - 让下划线淡入的问题

php - 为什么这个 <a> 标签上的 `background-image` 不可见?

html - 高级 CSS 挑战 : underline only the final line of text with CSS

php - 如何在 PHP 中将 11、22、33 转换为 10、20 和 30?