解决问题:子style.css不会覆盖父style.css

我知道以前曾有人问过这个问题, 但先前的问题都无济于事。

这是我的职责

function my_theme_enqueue_styles() {

$parent_style = 'flex-mag-style'; // This is 'flex-mag-style' for the Flex Mag theme.

wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'flex-mag-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', PHP_INT_MAX ); 

这两个样式表都加载, 但是在我检查时, 不会显示任何子styles.css规则。


#1


请尝试添加以下代码。它为我工作。

<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );

} ?>

希望你已经在子主题样式表中正确地将父主题名称提到为Template :(父主题的名称)


#2


子style.css的注释栏中有错字

与功能无关

来源:

https://www.srcmini02.com/62906.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_42076.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?