【问题标题】:CSS not working in wordpress website; call to undefined function get_template_uri() in functions.phpCSS 在 wordpress 网站中不起作用;在functions.php中调用未定义的函数get_template_uri()
【发布时间】:2019-04-15 04:27:36
【问题描述】:

我正在尝试创办一家公司并正在为该公司创建网站。当我实时查看网站时,它全是 html,没有 css,但我在 ehder 和 index.php 的 rel 样式表中链接了它,但仍然没有 css!所以我在网上做了一些研究并创建了一个functions.php文件,认为这是问题所在。现在我收到此错误

警告:add_action() 缺少参数 2,调用 /home2/elishaday/public_html/wp-content/themes/smmwca/css/functions.php 在第 7 行并在 /home2/elishaday/public_html/wp-includes/plugin.php 在第 405 行

致命错误:调用未定义的函数 get_template_uri() /home2/elishaday/public_html/wp-content/themes/smmwca/functions.php 第 5 行

这是我的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' );

【问题讨论】:

    标签: php html css wordpress


    【解决方案1】:

    警告显示您的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' );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      相关资源
      最近更新 更多