Brandon Nelson
asked 2 years ago

I have set up a child theme for DW Purity, but it is loading the child CSS prior to dw-purity.min.css so my custom styles are being overridden unless I use !important.
style.css header looks like this:
/*
Theme Name: DW Purity – CHILD
Author: 200 Megaton Creative, llc
Version: 1.0.0
Template: dw-purity
*/
functions.php looks like this:
<?php
function my_theme_enqueue_styles() {

    $parent_style = ‘dw-purity-style’; // This is ‘twentyfifteen-style’ for the Twenty Fifteen theme.

    wp_enqueue_style( $parent_style, get_template_directory_uri() . ‘/style.css’ );
    wp_enqueue_style( ‘dw-purity-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’ );
?>

4 Answers
DominicStaff
answered 2 years ago

You can add the following code to the style.css file:

/*
Theme Name: DW Purity Child
Author: 200 Megaton Creative, llc
Version: 1.0.0
Template: dw-purity
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: dw-purity-child
*/

And add the following code to the functions.php file:

<?php
 function my_theme_enqueue_styles() {
 $parent_style = 'parent-style'; // This is 'dw-purity-child' for the DW Purity 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' );
Brandon Nelson
answered 2 years ago

Thank you for looking into this. My child style sheet is still loading in front of the assets/css style sheets from the parent. Below is how the code is rendering. As you can see, the child CSS is right after the main CSS sheet, but then the other 4 style sheets from the assets/css folder load. How can I get my child link to show up last?
Take a look at the code here:
view-source:https://nuevo.senovva.com/

Dominic Staff
replied 2 years ago

Please send me username & password of your site for further checking, I will help you resolve this issue.

Brandon Nelson
answered 2 years ago

I don’t think the client will be OK with that on this one. Can you walk me through some things to look for? Not sure why, but the CSS ‘/themes/dw-purity/assets/css/dw-purity.min.css?ver=1.0.1’ is loading 3 times. But more importantly, my child CSS is loading just after the root level style.css in the parent theme folder. I just need the child CSS to load last.
https://www.dropbox.com/s/cu6lo413ik4o3wa/Screen%20Shot%202017-09-25%20at%208.09.18%20PM.png?dl=0

Brandon Nelson
answered 2 years ago

I ended up changing the design of the header file slightly so I just loaded the custom CSS file manually at the very end. It ends up loading twice, which is not the greatest but works for now. Looks like this theme was mostly set up to be customized through the admin to accept the new css from there. I noticed the inc/scripts.php file calls up all the other CSS files in the assets folder. Could this file be modified in future updates to allow child themes to load their style.css file after all the core CSS files?
I have a test site set up on SiteGround through my hosting that you can review.

I also just submitted another question on the Unyson Page Builder not saving content as well.
Thank you.

Dominic Staff
replied 2 years ago

I have checked and helped you resolve this issue, you can check your site now.

Brandon Nelson
replied 2 years ago

The only way I was able to get my custom CSS to load last was to manually add it my setting up a custom header.php file in my child theme directory. I just load it again manually at the very end. This ends up loading my custom CSS file twice, once by the function.php action, then when it loads with the hard coded link at the end of the revised header.php file. Any chance that this issue will be addressed in later updates?

Dominic Staff
replied 2 years ago

Yes, we are checking the theme to update in the next version. If you have an idea or the issues with our theme, you can let me know, we will check and discuss about it for the next version.

Powered by DW Question & Answer Pro