[英]Style.css not overwriting parent style.css although style.css and functions.php are set up
我已經嘗試解決這個問題兩天了,在這里查看不同的答案。
每當我在 WP 的“附加 CSS”編輯器中編輯 css 時,我都會得到想要的結果。 但是,我似乎無法從 style.css 表中執行此操作。 並不是說我需要從那里開始,但它向我表明我的子主題設置不正確。
我的 style.css 文件:
/*
Theme Name: Coblog-child
Template: coblog
Author: [name]
Description: Coblog Child
Version: 1.1.0.1588784301
Updated: 2020-05-06 16:58:21
*/
我的功能。php:
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
?>
知道這兩個有什么問題嗎?
謝謝
您只在您的函數中加載父樣式。php。 所以你不要加載你的子主題的 style.css。 為了使其工作,您還將將您的子主題的樣式表排入隊列:
function child_theme_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-theme-css', get_stylesheet_directory_uri() .'/style.css' , array('parent-style'));
}
add_action( 'wp_enqueue_scripts', 'child_theme_styles' );
對於模板目錄 uri(父主題)
get_template_directory_uri()
對於子主題目錄uri
get_stylesheet_directory_uri()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.