php - CSS 在 wordpress 网站中不起作用;在functions.php中调用未定义的函数get_template_uri()
问题描述
我正在尝试创办一家公司并为该公司创建网站。当我实时查看网站时,它全是 html,没有 css,但我在 ehder 和 index.php 的 rel 样式表中链接了它,但仍然没有 css!所以我在网上做了一些研究并创建了一个functions.php文件,认为这是问题所在。现在我收到此错误
警告:add_action() 缺少参数 2,在第 7 行的 /home2/elishaday/public_html/wp-content/themes/smmwca/css/functions.php 中调用并在 /home2/elishaday/public_html/wp-includes/plugin 中定义.php 在第 405 行
致命错误:在第 5 行的 /home2/elishaday/public_html/wp-content/themes/smmwca/functions.php 中调用未定义函数 get_template_uri()
这是我的functions.php 文件!
请帮忙
<?php
add_theme_support( 'post-thumbnails' );
function enqueue2_my_custom_styles(){
wp_enqueue_style('animate css', get_template_uri() . '/css/styles.css', array(), '1.0.0', 'all');
}
add_action( 'wp_enqueue_scripts', 'enqueue2_my_custom_styles' );
解决方案
警告显示您的 functions.php 位于另一个文件夹(css)中。functions.php 必须位于主题的根目录中。
另外,那get_template_directory_uri()
不是get_template_uri()
:
<?php
add_theme_support( 'post-thumbnails' );
function enqueue2_my_custom_styles(){
wp_enqueue_style('animate css', get_template_directory_uri() . '/css/styles.css', array(), '1.0.0', 'all');
}
add_action( 'wp_enqueue_scripts', 'enqueue2_my_custom_styles' );
推荐阅读
- sql-server - bcp out 默认排序,第一行和最后一行 par
- java - 分段上传失败
- python-3.x - multiprocessing.queue 模块丢失,直到 Queue 被实例化
- javascript - cypress- 将数据从一个页面发送到另一个页面(新标签)
- python - 如何使用用户名而不是用户 ID 从管理页面导出模型?
- alert - Nagios - 如何设置警报频率?
- r - 在现有函数对象的正文中添加一行
- java - 为什么我们必须在 while-true 循环中填充缓冲区?
- django - (djstripe.C001) 找不到 Stripe API 密钥。提示:将 STRIPE_TEST_SECRET_KEY 和 STRIPE_LIVE_SECRET_KEY 添加到您的设置中
- amazon-web-services - 如何在 StepFunction 状态机执行事件历史记录中获取胶水作业的资源链接?