【问题标题】:Child theme directory in wordpresswordpress 中的子主题目录
【发布时间】:2017-01-10 01:33:27
【问题描述】:

我是在 wordpress 中制作子主题的新手,我的子主题有问题。如果它被放置在我的父主题的其他目录中,我如何更改子主题中的 footer.php。在这里,父主题将footer.php放在hooks->footer.php下 父主题页脚目录:

这是我要更改页脚的子主题 我的孩子主题的目录? :

这是我的孩子主题functions.php:

<?php
//
// Recommended way to include parent theme styles.
//  (Please see http://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme)
//  
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
    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')
    );
}
//
// Your code goes below
//

【问题讨论】:

    标签: php html css wordpress content-management-system


    【解决方案1】:

    正确绑定父子主题的方法是使用 wp_enqueue_scripts 动作,并在子主题的functions.php中使用wp_enqueue_style(),如下所示。

        <?php
        function my_theme_enqueue_styles() {
    
           $parent_style = 'parent-style'; // This is 'twentyfifteen-style' for     the Twenty Thirteen theme.
    
        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 ),
            wp_get_theme()->get('Version')
        );
    }
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    ?>
    

    http://www.codextutor.com/creating-child-theme-in-wordpress/查看更多详情

    希望对你有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-09
      • 1970-01-01
      • 2020-07-28
      • 2016-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多