我设置了一个儿童主题并让它运作良好。但是,现在每当我进行任何更改时,它们都不会在网站上反映数小时。他们最终更新,但直到很长一段时间才过去。
而且,我还应该说我没有缓存插件,而且我已经清除了浏览器缓存。
当我从孩子切换到父主题时,旧的CSS和javascript消失了。并且,当我再次激活子主题时,旧的css和javascript重新出现,但没有任何新的更改。
这是我的子function.php文件的代码:
<?php
//* Code goes here
function my_theme_enqueue_styles() {
$parent_style = 'zero'; // This is 'zero-style' for the Zero theme.
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' );
function zero_child_script() {
wp_enqueue_script('zero child script', get_stylesheet_directory_uri() . '/zero_child_script.js');
}
add_action('wp_enqueue_scripts', 'zero_child_script');
这是我的子style.css文件的代码:
/*
Theme Name: Zero Child
Theme URI:
Description: A Child them of The Zero Creative theme for WordPress OpalTeam is a fully responsive theme that looks great on any device. That's the best for any kind of crowdfunding online sites. Follow us on Themeforest to receive newest updates</a>
Author: The Opal Wordpress Team
Author URI: http://
Template: zero
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: black, green, white, light, dark, two-columns, three- columns, left-sidebar, right-sidebar, fixed-layout, responsive-layout, custom-background, custom-header, custom-menu, editor-style, featured- images, flexible-header, full-width-template, microformats, post-formats, rtl-language-support, sticky-post, theme-options, translation-ready, accessibility-ready
Text Domain: zero-child
*/
/*Glossary
1. Header Styles
2. Slider Styles
*/
/*=====1. Header Styles=====*/
@media only screen and (min-width: 1230px) {
.logo-wrapper {
width: 35% !important;
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
-ms-transition: all .5s ease;
-o-transition: all .5s ease;
transition: all .5s ease;
}
}
/*=====2. Slider Styles=====*/
h1#type-text {
text-shadow: 0 0 20px rgba(0,0,0,0.5);
}
子主题中的javascript文件:
//Add background to logo on scroll
function ScrollBg(){
var bg = document.getElementsByClassName('logo-wrapper')[0];
var ypos = window.pageYOffset;
var screenWidth = '1229';
if (window.screen.width > screenWidth) {
if (ypos > 589) {
bg.style.backgroundColor = "rgba(0,0,0,0.5)";
}
else{
bg.style.backgroundColor = "rgba(0,0,0,0)";
}
}
}
window.addEventListener("scroll", ScrollBg);
网址为http://c2pm.misterekwebdesign.com
我也尝试过根据这篇文章更改.htaccess重写规则 (Wordpress child theme stylesheet doesn't seem to work) 看看是否修复它但它没有用。