【问题标题】:WP Child Theme's style.css working on one site but not on anotherWP Child Theme 的 style.css 在一个站点上工作,但在另一个站点上不工作
【发布时间】:2017-06-23 14:55:36
【问题描述】:

我创建了 Wordpress 罗琳主题的子主题。 我的 style.css 包含以下内容:

    /*
    Theme Name: MF2017
    Theme URI: 
    Description: rowling Child Theme
    Author: Kathrin Herwig
    Author URI: https://schriftbild.net
    Template: rowling
    Version: 1.0.0
    */

和functions.php这个:

    <?php
    /**
    * Enqueue scripts and styles.
    */
    function namescript_scripts() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
      wp_enqueue_style( 'child-style',
      get_stylesheet_directory_uri() . '/style.css',
      array('parent-style')
      );
    }
    add_action( 'wp_enqueue_scripts', 'namescript_scripts' );

     ?>

子主题的 css 加载到我的 test-webspace 上,图像周围的类 .grau: grey 框架来自子主题的 css)。 但不在real website 上。 (.grau 未加载)

我尝试了所有方法,但无法成功。

【问题讨论】:

    标签: css wordpress wordpress-theming child-theming


    【解决方案1】:

    似乎与访问权限/文件权限有关:当我使用浏览器工具/样式并单击子主题 style.css 时,或者当我单击源代码中 CSS 文件的链接时,我会看到这个:

    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>403 Forbidden</title>
    </head><body>
    <h1>Forbidden</h1>
    <p>You don't have permission to access /wp-content/themes/MF2017/style.css
    on this server.</p>
    </body></html>
    

    所以不允许浏览器加载样式表。检查该服务器上文件及其文件夹的访问权限/文件权限并将其设置为公共。

    【讨论】:

    • 没错!我用cyberduck将UNIX访问权限更改为“755”,现在它可以工作了。
    【解决方案2】:

    可能是你弄乱了主题名称。子主题名称应为“主题名称孩子”,如“罗琳孩子”按照下面的代码,

    /*
     Theme Name:   Rowling Child
     Theme URI:    http://example.com/rowling-child/
     Description:  Rowling Child Theme
     Author:       Kathrin Herwig
     Author URI:   https://schriftbild.net
     Template:     rowling
     Version:      1.0.0
     Text Domain:  rowling-child
    */
    

    更多详情请查看此链接https://codex.wordpress.org/Child_Themes

    【讨论】:

    • 我试过了,但没有任何改变。顺便说一句,我认为您可以为子主题选择任何您想要的名称,只要“描述”和“模板”行是正确的?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-28
    • 1970-01-01
    • 2012-09-17
    • 1970-01-01
    • 2018-01-30
    • 1970-01-01
    • 2012-02-07
    相关资源
    最近更新 更多