Ser*_*rgi 4 css php wordpress parent-child
我创建了第二十七个主题的子主题。在孩子的主题文件夹中,我有一个“ style.css”和一个“ functions.php”文件。在style.css文件中,我具有:
/*
Theme Name: Personal_theme
Theme URI: http://wordpress:8888/
Description: This is a child theme of twentyseventeen
Author: My name
Author URI: ...
Template: twentyseventeen
Version: 0.1;
*/
.entry-title {
color: blue;
}
Run Code Online (Sandbox Code Playgroud)
并在functions.php内部:
<?php
function my_theme_enqueue_styles() {
$parent_style = 'parent-style';
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' );
?>
Run Code Online (Sandbox Code Playgroud)
如果我添加“!重要!” 风格,它会变成蓝色。如果使用检查器工具,则可以看到在父级之后加载了子样式表,但是父级覆盖了样式。我是Wordpresss的新手,functions.php中的任何参数是否错误?我必须改变一些东西吗?
| 归档时间: |
|
| 查看次数: |
8693 次 |
| 最近记录: |