我是在wordpress中制作儿童主题的新手,我的childtheme存在问题。如果将footer.php放在父主题的其他目录中,如何更改子主题中的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
//
最佳答案
绑定父主题和子主题的正确方法是使用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/