gpt4 book ai didi

php - 主题子文件夹中的 CSS 文件无法正常工作 wordpress?

转载 作者:行者123 更新时间:2023-11-28 04:29:15 26 4
gpt4 key购买 nike

我在搜索了很多之后问了这个问题,但任何技巧和答案都不起作用。我是新手,创建了自己的自定义主题。我按如下方式在我的主题目录中上传了很棒的自定义字体

  • -Gohilar-字体
  • --CSS
  • ---gohilar-font-embedded.css
  • --字体
  • ---gohilar-font.woff

现在的问题是,当我将这个 css 文件链接到我的 header.php 时,它没有链接,即使我在许多网站上尝试了所有建议......但是它在我的本地计算机上正常工作,即 localhost

我在header.php中head下添加了css代码如下

  <link rel="stylesheet" href="<?php echo esc_url( get_template_directory_uri() ); ?>/gohilar-font/css/gohilar-font-embedded.css">

如果我链接http://newser.in/wp-content/themes/Gohilar/gohilar-font/css/gohilar-font-embedded.css当前未打开并显示 404 错误

最佳答案

包含 css 文件的推荐方法是使用 wp_enqueue_style。只需将以下代码添加到您的 function.php 并调整文件名和路径即可。

// load bootstrap css
wp_enqueue_style( '_tk-bootstrap', get_template_directory_uri() . '/includes/resources/bootstrap/css/bootstrap.min.css' );

来源:https://developer.wordpress.org/reference/functions/wp_enqueue_style/

关于php - 主题子文件夹中的 CSS 文件无法正常工作 wordpress?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41815400/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com