gpt4 book ai didi

php - wordpress 中的子主题目录

转载 作者:行者123 更新时间:2023-11-28 05:16:33 24 4
gpt4 key购买 nike

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

这是我的子主题,我想在其中更改页脚我的 child 主题的目录? : Child theme directory

这是我的子主题 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
//

最佳答案

绑定(bind)父主题和子主题的正确方法是使用 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/ 中查看更多详细信息

希望对你有所帮助。

关于php - wordpress 中的子主题目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39283843/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com