简体   繁体   English

创建一个子主题

[英]Creating a child theme

I am trying to create a child theme but I think that there is something wrong with my functions.php. 我正在尝试创建一个儿童主题,但我认为我的functions.php出了点问题。

(<?php)add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'sydney', get_template_directory_uri() . '/style.css' );

}function theme_enqueue_styles() {

$parent_style = 'sydney';

wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'sydney-child',
    get_stylesheet_directory_uri() . '/style.css',
    array( $parent_style )
);
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );

May Be this problem is due to function.php file in your child theme. 可能是由于子主题中的function.php文件引起的。

Child theme's functions.php is loaded first implies that you can create the user functions of your theme pluggable - that are replaceable by a child theme - by mentioning them restrictively. 首先加载子主题的functions.php意味着您可以通过限制性地提及主题来创建可插入主题的用户功能(可被子主题替换)。 Eg: 例如:

if ( ! function_exists( 'theme_special_nav' ) ) {
    function theme_special_nav() {
        //  Do something.
    }
}

In that way, a child theme can replace a PHP function of the parent by simply declaring it beforehand. 这样,子主题可以通过简单地事先声明来代替父主题的PHP函数。

for further reference please visit : Wordpress Child Theme 有关更多参考,请访问: Wordpress儿童主题

If you find my answer helpful please mark it, So others can take the benefits of it. 如果您发现我的答案有帮助,请标记它,以便其他人可以从中受益。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM