我的网站缺少我的父主题css。
我使用此functions.php
:
<?php
function my_theme_enqueue_styles() {
$parent_style = 'sydney'; //parent theme
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'RGUCCalendar', //child theme
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
);
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>
我的网站标题是:
<link rel='stylesheet' id='dashicons-css' href='http://wordpress.rguc.co.uk/wp-includes/css/dashicons.min.css?ver=4.9.5' type='text/css' media='all' />
<link rel='stylesheet' id='admin-bar-css' href='http://wordpress.rguc.co.uk/wp-includes/css/admin-bar.min.css?ver=4.9.5' type='text/css' media='all' />
<link rel='stylesheet' id='tribe-events-bootstrap-datepicker-css-css' href='http://wordpress.rguc.co.uk/wp-content/plugins/the-events-calendar/vendor/bootstrap-datepicker/css/bootstrap-datepicker.standalone.min.css?ver=4.9.5' type='text/css' media='all' />
<link rel='stylesheet' id='sydney-bootstrap-css' href='http://wordpress.rguc.co.uk/wp-content/themes/sydney/css/bootstrap/bootstrap.min.css?ver=1' type='text/css' media='all' />
<link rel='stylesheet' id='contact-form-7-css' href='http://wordpress.rguc.co.uk/wp-content/plugins/contact-form-7/includes/css/styles.css?ver=5.0.1' type='text/css' media='all' />
<link rel='stylesheet' id='lsow-frontend-styles-css' href='http://wordpress.rguc.co.uk/wp-content/plugins/livemesh-siteorigin-widgets/assets/css/lsow-frontend.css?ver=1.7.3' type='text/css' media='all' />
<link rel='stylesheet' id='lsow-icomoon-styles-css' href='http://wordpress.rguc.co.uk/wp-content/plugins/livemesh-siteorigin-widgets/assets/css/icomoon.css?ver=1.7.3' type='text/css' media='all' />
<link rel='stylesheet' id='tribe-events-custom-jquery-styles-css' href='http://wordpress.rguc.co.uk/wp-content/plugins/the-events-calendar/vendor/jquery/smoothness/jquery-ui-1.8.23.custom.css?ver=4.9.5' type='text/css' media='all' />
<link rel='stylesheet' id='tribe-accessibility-css-css' href='http://wordpress.rguc.co.uk/wp-content/plugins/the-events-calendar/common/src/resources/css/accessibility.min.css?ver=4.7.13' type='text/css' media='all' />
<link rel='stylesheet' id='tribe-events-full-calendar-style-css' href='http://wordpress.rguc.co.uk/wp-content/plugins/the-events-calendar/src/resources/css/tribe-events-full.min.css?ver=4.6.16' type='text/css' media='all' />
<link rel='stylesheet' id='tribe-events-calendar-style-css' href='http://wordpress.rguc.co.uk/wp-content/plugins/the-events-calendar/src/resources/css/tribe-events-theme.min.css?ver=4.6.16' type='text/css' media='all' />
<link rel='stylesheet' id='tribe-events-calendar-full-mobile-style-css' href='http://wordpress.rguc.co.uk/wp-content/plugins/the-events-calendar/src/resources/css/tribe-events-full-mobile.min.css?ver=4.6.16' type='text/css' media='only screen and (max-width: 768px)' />
<link rel='stylesheet' id='tribe-events-calendar-mobile-style-css' href='http://wordpress.rguc.co.uk/wp-content/plugins/the-events-calendar/src/resources/css/tribe-events-theme-mobile.min.css?ver=4.6.16' type='text/css' media='only screen and (max-width: 768px)' />
<link rel='stylesheet' id='tribe-events-admin-menu-css' href='http://wordpress.rguc.co.uk/wp-content/plugins/the-events-calendar/src/resources/css/admin-menu.min.css?ver=4.6.16' type='text/css' media='all' />
<link rel='stylesheet' id='tribe-events-full-pro-calendar-style-css' href='http://wordpress.rguc.co.uk/wp-content/plugins/events-calendar-pro/src/resources/css/tribe-events-pro-full.min.css?ver=4.4.26' type='text/css' media='all' />
<link rel='stylesheet' id='tribe-events-calendar-pro-style-css' href='http://wordpress.rguc.co.uk/wp-content/plugins/events-calendar-pro/src/resources/css/tribe-events-pro-theme.min.css?ver=4.4.26' type='text/css' media='all' />
<link rel='stylesheet' id='tribe-events-calendar-full-pro-mobile-style-css' href='http://wordpress.rguc.co.uk/wp-content/plugins/events-calendar-pro/src/resources/css/tribe-events-pro-full-mobile.min.css?ver=4.4.26' type='text/css' media='only screen and (max-width: 768px)' />
<link rel='stylesheet' id='tribe-events-calendar-pro-mobile-style-css' href='http://wordpress.rguc.co.uk/wp-content/plugins/events-calendar-pro/src/resources/css/tribe-events-pro-theme-mobile.min.css?ver=4.4.26' type='text/css' media='only screen and (max-width: 768px)' />
<link rel='stylesheet' id='sydney-css' href='http://wordpress.rguc.co.uk/wp-content/themes/sydney/style.css?ver=4.9.5' type='text/css' media='all' />
<link rel='stylesheet' id='RGUCCalendar-css' href='http://wordpress.rguc.co.uk/wp-content/themes/RGUCCalendar/style.css?ver=1.0.0' type='text/css' media='all' />
<link rel='stylesheet' id='sydney-fonts-css' href='https://fonts.googleapis.com/css?family=Source+Sans+Pro%3A400%2C400italic%2C600%7CRaleway%3A400%2C500%2C600' type='text/css' media='all' />
<link rel='stylesheet' id='sydney-style-css' href='http://wordpress.rguc.co.uk/wp-content/themes/RGUCCalendar/style.css?ver=20180213' type='text/css' media='all' />
<style id='sydney-style-inline-css' type='text/css'>
.site-title { font-size:32px; }
.site-description { font-size:16px; }
#mainnav ul li a { font-size:14px; }
h1 { font-size:52px; }
h2 { font-size:42px; }
h3 { font-size:32px; }
h4 { font-size:25px; }
h5 { font-size:20px; }
h6 { font-size:18px; }
body { font-size:16px; }
.single .hentry .title-post { font-size:36px; }
.header-image { background-size:cover;}
.header-image { height:300px; }
.site-header.float-header { background-color:rgba(0,0,0,0.9);}
@media only screen and (max-width: 1024px) { .site-header { background-color:#000000;}}
.site-title a, .site-title a:hover { color:#ffffff}
.site-description { color:#ffffff}
#mainnav ul li a, #mainnav ul li::before { color:#ffffff}
#mainnav .sub-menu li a { color:#ffffff}
#mainnav .sub-menu li a { background:#1c1c1c}
.text-slider .maintitle, .text-slider .subtitle { color:#ffffff}
body { color:#47425d}
#secondary { background-color:#ffffff}
#secondary, #secondary a, #secondary .widget-title { color:#767676}
.footer-widgets { background-color:#252525}
.btn-menu { color:#ffffff}
#mainnav ul li a:hover { color:#d65050}
.site-footer { background-color:#1c1c1c}
.site-footer,.site-footer a { color:#666666}
.overlay { background-color:#000000}
.page-wrap { padding-top:83px;}
.page-wrap { padding-bottom:100px;}
@media only screen and (max-width: 1025px) {
.mobile-slide {
display: block;
}
.slide-item {
background-image: none !important;
}
.header-slider {
}
.slide-item {
height: auto !important;
}
.slide-inner {
min-height: initial;
}
}
@media only screen and (max-width: 780px) {
h1 { font-size: 32px;}
h2 { font-size: 28px;}
h3 { font-size: 22px;}
h4 { font-size: 18px;}
h5 { font-size: 16px;}
h6 { font-size: 14px;}
}
</style>
我的孩子主题是:
/*
Theme Name: RGUCCalendar
Theme URI: http://example.com/twenty-fifteen-child/
Description: Sydney Child Theme
Author: xxx
Author URI: http://example.com
Template: sydney
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: RGUCCalendar
*/
我的主题设置如下:
wp-content/themes/sydney
wp-content/themes/RGUCCalendar
如何让我的孩子主题使用父主题css?
答案 0 :(得分:0)
请尝试以下代码我正在使用此代码,它在我的网站上运行。
<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles', PHP_INT_MAX);
function my_theme_enqueue_styles() {
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') );
}
?>