【问题标题】:Wordpress child theme issueWordpress 儿童主题问题
【发布时间】:2018-10-07 15:32:46
【问题描述】:

我正在为我的 Wordpress 主题使用自制的子主题。因为我有很多文件,所以我在我的子主题中添加了一些文件夹并更改了 functions.php 中的路径以使其更清晰:


我的文件夹结构:

现在我遇到了 Wordpress 无法加载我的文件的问题:

(index):53 GET http://localhost/wordpress/wp-content/themes/Divicss/style.css?ver=4.9.8 net::ERR_ABORTED 404 (Not Found)

看起来 Wordpress 正在搜索原始主题,但这是错误的。我怎样才能解决这个问题?或者这甚至可能吗?

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    get_template_directory_uri 返回父主题的路径。你必须使用get_stylesheet_directory_uri。另外,请记住它不会在末尾附加斜杠,因此您必须自己做。

    wp_enqueue_style('main_css', get_stylesheet_directory_uri() . '/css/style.css');
    

    根据developer documentation style.css 是一个必需的文件,所以也许你根本不能移动那个特定的文件,或者至少需要一个带有孩子节的虚拟文件。

    【讨论】:

    • 我稍后再试试。我希望这适用于儿童主题
    • 将其设置为同样的问题
    • @Johnny97 您的所有文件都有问题吗?用链接更新答案。
    • 根据Wordpress,子主题主css不能移动到其他文件夹。
    猜你喜欢
    • 1970-01-01
    • 2020-03-06
    • 2013-12-03
    • 2017-06-06
    • 2014-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-25
    相关资源
    最近更新 更多