簡體   English   中英

創建一個子主題

[英]Creating a child theme

我正在嘗試創建一個兒童主題,但我認為我的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' );

可能是由於子主題中的function.php文件引起的。

首先加載子主題的functions.php意味着您可以通過限制性地提及主題來創建可插入主題的用戶功能(可被子主題替換)。 例如:

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

這樣,子主題可以通過簡單地事先聲明來代替父主題的PHP函數。

有關更多參考,請訪問: Wordpress兒童主題

如果您發現我的答案有幫助,請標記它,以便其他人可以從中受益。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM