I know this has been brought up a million times on here, but I have followed various solutions to no avail. My child theme stylesheet just won't change. It actually seems like any changes I make to the child functions.php don't take effect.
This is the closest post to my issue is this one but the answer about cache busting hasn't worked for me. I am kind of thinking it has to do with how the parent theme enqueues child theme styles automatically, but I don't know how to override that.
functions.php styles enqueue:
// Load styles:
add_action( 'wp_enqueue_scripts', 'main_styles' );
function main_styles() {
//* Bootstrap CSS
wp_enqueue_style('bootstrap-style', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css');
//* Parent CSS
wp_enqueue_style( 'corporate-plus',
get_template_directory_uri() . '/style.css' );
//* Child theme CSS
$cache_buster = date("YmdHi", filemtime( get_stylesheet_directory() . '/style.css'));
wp_enqueue_style( 'yunev-corporate-plus',
get_stylesheet_directory_uri() . '/style.css',
array( 'corporate-plus '),
$cache_buster
);
}
child theme style.css theme comments:
/*
Theme Name: Yunev Custom
Description: Yunev Custom - Corporate Plus Child Theme
Template: corporate-plus
Version: 1.1.2
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: yunevcorporatepluschild
*/
(I removed the author and such for this post)
I customized this child theme a while ago and the custom styles are working, but any changes I make now don't propagate. I have cleared cloudflare cache, cache plugin, everything I can think of. It's driving me crazy.
The child style version that I get in the browser is always '1.0.1'. Any troubleshooting tips would be much appreciated.
Just try to rename your stylesheet or reupload your theme.
Related
I'm building a wp child theme of ThemeGrill's ColorMag. When I load the page, my child theme css file is loaded, but there is also a file called style.css?ver=5.3.2 loaded after it. When I look at the code under elements in the dev tools, it appears to be a cached version of my style.css file.
I've deleted the child theme folder and reuploaded all of my files but I see the same result. I also have wp-cache level set to 0
Also I should note, I'm new to wp and couldn't figure out how to enqueue the child theme properly, so style.css is loaded via an href in my header.php. my functions.php looks like this:
<?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' );
}
Again, I'm new so any best practices you have would be much appreciated!
Site is here.
I'm using a child theme with HTML5 Blank as the parent theme. I've used this before without any issue but for some reason I'm now getting the following error on my themes page -
Broken Themes
The following themes are installed but incomplete.
Name Description
HTML5 Blank Child Theme The parent theme is missing. Please install the "html5blank" parent theme.
This is what I have in my folder -
style.css
/*
Theme Name: HTML5 Blank Child Theme
Description: A child theme of the HTML5 Blank WordPress theme
Author: Mike Whitehead
Template: html5blank
Version: 1.0.0
*/
I've tried numerous different variations on this - also copying the official wordpress guide. The above wording worked for me on my last project so don't know why it won't work now.
This is my functions file -
functions.php
<?php
function my_theme_enqueue_styles() {
$parent_style = 'html5blank-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen 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' );
?>
Not sure why this isn't working. Any assistance would be appreciated.
The child themes style.css 'Template' tag should match that of the parent themes folder name eg.
/*
Theme Name: HTML5 Blank Child Theme
Description: A child theme of the HTML5 Blank WordPress theme
Author: Mike Whitehead
Template: html5blank-stable
Version: 1.0.0
*/
As per the WordPress Codex page on Child Themes - https://codex.wordpress.org/Child_Themes
"The Template line corresponds to the directory name of the parent theme. The parent theme in our example is the Twenty Fifteen theme, so the Template will be twentyfifteen. You may be working with a different theme, so adjust accordingly."
Get Your Parent Theme's Textdomain and put it as child theme's Template name. Let's say your Parent theme's Style.css header like this...
/*
Theme Name: HTML5 Parent Theme
Description: A HTML5 Blank Parent WordPress theme
Author: Mike Whitehead
Text domain: html5blank
Version: 1.0.0
*/
Then you can use this Text domain name into your child theme like this..
/*
Theme Name: HTML5 Blank Child Theme
Description: A child theme of the HTML5 Blank WordPress theme
Author: Mike Whitehead
Template: html5blank
Version: 1.0.0
*/
I am putting together a wordpress child theme based on a parent theme that has multiple style sheets in it's directory. So for example this is the navigation to a few of the style sheets:
parent-theme/style.css
parent-theme/css/style.css
parent-theme/css/bootstrap.css
I created my child folder and created my style.css file as well as my function.php file but it seems that the child theme is only pulling the style sheet for the parent-theme/style.css file and not pulling all the .css files.
After doing some digging this is where my functions.php file is at currently:
<?php
/* v1.0.5
Date: 5/15/17
*/
function my_theme_enqueue_styles() {
$parent_style = 'wizard-style'; // This is 'wizard' for the Wizard theme.
wp_enqueue_style( $parent_style, get_template_directory_uri() . 'style.css' );
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/css/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' );
?>
My main objective is to have the child theme pull all needed stylesheets and utilize the one single style sheet under my child them folder (child-theme/style.css) for any changes I would like to make.
My questions are:
Is this possible?
If it is possible, what errors may be occurring that is causing my fucntion.php file not to pull all the stylesheets?
If it is not possible, what changes do I need to make to my function.php file and my directory to make this work?
I had an issue like this with ArileWP theme, after a lot of research I figured out that loading multiple style sheets was not the issue (using the enqueue function on wordpress.org forums and other forums did in fact load all stylesheets regardless of whether they were in the root level or lower directory levels of the parent theme).
The issue in my case ended up being that Arile requires you to install their "arile extra" plugin, and this plugin has an if statement that is conditional on what your child theme is named:
if( 'ArileWP' == $activate_theme || 'Business Street' == $activate_theme || 'StrangerWP' == $activate_theme || 'NewYork City' == $activate_theme || 'InteriorPress' == $activate_theme || 'Arile WP Child' == $activate_theme ){
require("inc/arilewp/arilewp.php");
Their plugin has a default name Arile WP Child that, if you are not using as the name of your child theme, the extra features included in the plugin will not execute.
The cleanest solution in my case was to simply change the name of my child theme to the one defaulted in their php file.
Might not be the same issue you are having but was a simple fix that just took me a long time to narrow down.
Check the page 'view source' to make sure the style sheets are being loaded from the parent. When you activate a child theme its still pulling everything from the parent unless you override the specific file (example: header.php).
The functions.php and style.css files are the only exception as they supplement their corresponding parent theme file.
So, in summary those stylesheets should be included on your websites. Your theme settings may be incorrect but if you're in a pinch and just need to get those style sheets loaded just add them manually via the functions.php file by
enqueuing them
EDIT:
Does the child theme stylesheet contain the following commented out information customized for your theme, of course?
/*
Theme Name: Twenty Fifteen Child
Theme URI: URI
Description: Twenty Fifteen Child Theme
Author: John Doe
Template: twentyfifteen
Version: 1.0.0
Text Domain: twenty-fifteen-child
*/
If it isn't overriding the parent the styles it could possibly be a cache issue. If you don't have any cache plugins it could be your hosting environment or Cloudflare. If you can clear the server cache then refresh your browser with a Cntrl+F5 and see if that helps.
Did you try adding !important to your child styles for troubleshooting purposes already? Does your theme have a custom style option that lets to save styles to the database that it loads with each page to override the parent theme? Its not ideal but works if youre in a pinch.
Sorry if I am telling you elementary things I am not sure what your experience level is.
I'm having so much trouble setting up a child theme of the html5blank theme. To the point where I'm doing a fresh install of the parent theme and starting from scratch - and writing this post as I go through it! Basically upon creating the child them I now need to load my custom /css/main.css file - and it's not having it! Description of setup process follows:
I've dropped a freshly downloaded html5blank folder into /themes/ and activated it. After that I have created another folder within /themes/ called "html5blank-child". Within that I've created a new, blank style.css and functions.php.
Within style.css I have the following:
/*
Theme Name: HTML5 Blank Child
Theme URI: http://example.com/twenty-fifteen-child/
Description: HTML5 Blank Child Theme
Author: My Name
Author URI: http://myportfolio.com
Template: html5blank
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: html5blank-child
*/
And within functions.php I have:
<?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' );
}
?>
With all that done, I active my child theme. With all that done, everything still appears to be working. As I've created static templates of the website, I drop my 'img', 'css', 'font' and 'js' folders into the html5blank-child.
Now my 'actual' CSS file has a path of: html5blank-child/css/main.css
I need to load this file in. I was told to adjust my functions.php CSS path to: /css/main.css ...but it won't load the file at all. I've also tried using get_stylesheet_directory_uri() instead of get_template_directory_uri() as was advised by someone else but no luck!
The reason I've documented the process like this is, last time I got to this point if I went to access the Wordpress admin using http://localhost:8888/websitename/admin it won't redirect to wp-admin like it normally does. Also when I went to save a post, I've get a blank page. Thankfully that isn't happening this time so I guess it's a good (better) start but now I need to get my files loaded in.
Hope someone can help! :)
You need to import the style.css from main theme first inside the style.css of the child theme.
Use #import to import the css file first.
Also remove the parent-style from functions.php of child theme and then include your html5blank-child/css/main.css like the following given,
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
wp_enqueue_style( 'child-main', get_stylesheet_directory_uri() . '/css/main.css' );
}
Load the parent themes style.css first, then load your child themes CSS like this:
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' );
wp_enqueue_style( 'child-main', get_stylesheet_directory_uri() . '/css/main.css', array('parent-style') );
}
I am having the hardest time trying to modify the woocommerce layout for the storefont template. My directory is:
Location for woocommerce plugin: wp-content/plugins/woocommerce/templates
I copy everything in the templates folder above into: wp-content/themes/storefront_child/woocommerce/
Modify any file inside the woocommerce folder above such as writing
OMG anywhere on the page.
Nothing shows in my page.
I am a rookie in WordPress and I have no idea how to modify the files for a plugin/template. I have not activated my child template either (is that required?). When I duplicate the woocommerce files and try to install them, it says the template is missing.
open up functions.php
then copy below code on there:
add_action( 'after_setup_theme', 'woocommerce_support' );
function woocommerce_support() {
add_theme_support( 'woocommerce' );
}
and then check the result
I finally got it after much research. Most sites neglect to mention that what actually "activates" the child theme is the comment in the CSS. So the child theme MUST include the CSS with the information that links it to the parent child. In my case:
/*
Theme Name: storefront-child
Theme URI: http://example.com/
Description: StoreFront
Author: John Doe
Author URI: http://example.com
Template: storefront
Version: 1.3.1
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: twenty-fifteen-child
*/
It seems your child theme has not configured properly. You please double check below points.
You activated Child Theme (Not the parent)
Your child theme has a style.css file with below code
/*
Theme Name: My Child Theme
Description: A Twenty Thirteen child theme
Author: My author
Template: twentythirteen
Version: 1.0.0
*/
You properly Enqueued the Styles and Scripts.
add_action( 'wp_enqueue_scripts', 'my_theme_add_stylesheet' );
function my_theme_add_stylesheet() {
wp_enqueue_style( 'my-style', get_stylesheet_directory_uri() . '/style.css', false, '1.0', 'all' );
}