Wordpress child theme style.css has stopped working - php

really hoping someone can please help me! I just updated the Divi parent theme on my Wordpress site (www.ellymacdonalddesign.com), and the child CSS theme seems to have stopped working.
I've tried the solutions from this question, but they do not seem to work for me:
Wordpress child theme style.css not working
My child functions.php file is currently:
<?php
function my_theme_enqueue_styles() {
$parent_style = 'divi-style';
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( $child-style, get_stylesheet_uri() );
}
?>
Would really appreciate any guidance please, thank you in advance,
Elly

Is your variable $child-style have any value? According to document, the handle name (first parameter) is required. That's why your child theme still not working.
Try below code to see if it's work:
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
$parent_style = 'divi-style';
$child_style = 'divi-style-child';
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( $child_style, get_stylesheet_uri() );
}

Changing the css child theme version number helped solve the problem on my website.
My child theme was working correctly until I decided to change some css rules in the style.css file from the Wordpress 'Theme Editor' interface. I remarked that no changes appeared on the website, although the css was obviously loaded in the header and also I purged all cache.
I tried solutions of the following question but I think this is for new child theme installation, not an already working one: Wordpress child theme style.css not working
I decided to change the version number of my child theme, and the modifications were finally taken into account.
/*
Theme Name: Chromatic-child
Template: chromatic
Version: 1.1.0
*/

Related

Cached version of child theme css loading after updated css file?

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.

Unable to create a Wordpress child theme

So I'm trying to create a child theme called premierpas from the wordpress theme "fullscreen-agency". I create the premierpas folder in the themes, then I added a css file with that content :
/*
Theme Name: Premier Pas
Author: Garga Le Noir
Template: fullscreen-agency
Version: 1.0.0
*/
and a functions.php with this content :
<?php
function premierpas_enqueue_styles() {
$parent_style = 'fullscreen-agency';
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 ),null);
}
I've tried quite a few other versions of the functions code, without success.
When I try to activate it, my website just breaks. I only have a message telling me there is a technical problem, and I get an email to activate the recovery mode.
I'm sure the error is trivial and I'm sorry if I'm wasting your time, but I'm quite stuck on this... Any help will be appreciated, thanks in advance
I created a child theme with the code you stated above and it worked for me. The one change I made was I set the parent to be twentyfifteen since I didn't have your fullscreen-agency parent theme. I assumed your file paths were...
wp-content/themes/premierpas/style.css
wp-content/themes/premierpas/functions.php
A couple things to try...
Remove your functions.php file. If that solves the issue then perhaps you already have premierpas_enqueue_styles() defined in your parent theme or there is some related error.
Enable the debug.log by adding the following to your wp-config.php file... define( 'WP_DEBUG', true ); then try reactivating the child theme and look at your wp-content/debug.log file to see if there are any relevant errors thrown that can help you troubleshoot further.

Enqueuing Divi Child Theme But Styles Don't Override

I am using the DIVI theme and am trying to enqueue the child theme to override the parent theme. Here is the code in my functions.php:
// Queue parent style followed by child/customized style
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles', PHP_INT_MAX);
function 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' ) );
}
When I view source, everything is in the correct place. However, code in the child theme is not overriding code in the parent style. I've tried being more specific in my selectors, but no luck.
I've tried various versions of the enqueue code, I can see where my CSS is being called, but being overwritten by Divi's CSS.
While this isn't my favorite theme to work with, I'm stuck with it for this client. If possible, I'd prefer to have my separate stylesheet work vs using the customizer or other workarounds.
Is there a way to do this?
EDIT The enqueue works as is. I wasn't being specific enough in the child theme CSS to override the DIVI default CSS.

Wordpress Child theme for html5blank

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') );
}

Divi Child Theme Breaks Wordpress Customizer

I am having an issue with the wordpress customizer and Divi. Customizer works fine with just Divi activated, but when I activate a child theme the customizer suddenly stops working. It displays on the user facing side, but will not render in customizer.
I get this error from Chrome:
"bpmmarketing.com redirected you too many times."
So I of course made sure my functions file was kosher, which it is.
Here's that code (from elegant themes):
<?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' );
?>
I am seeing this error in the console:
load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,jquery-ui-core,jquery-ui-widget,jquery-ui-mo…:3
GET
http://bpmmarketing.com/?customize_changeset_uuid=9610c2a0-37d1-4b5a-abd6-d…ccfb7c&customize_theme=BPM+Marketing&customize_messenger_channel=preview-0
net::ERR_TOO_MANY_REDIRECTS
We have the site protected right now, but please let me know if you need any other information.
Your theme folder might contain spaces, for example "Divi child". If so you must change it to "Divi-child" and problem solved.
If not you can set the permalinks to plain as a workaround, but this is not good for SEO.

Categories