0

i created a child-theme for the theme customify, and wordpress is recognising the theme and loading it.

There were some changes though that were not getting through, and i was paying attention to the css selectors to see if something was being missed, then i found a topic with someone suggesting to check the loading order, and correctly enough, the minified stylesheet of the parent, loads after the child theme stylesheet.

If i cheat a bit the code, enqueuing the parent's minified style instead of the general one, and removing/matching the version number of the child's style, the minified css loads before, but still the css changes don't override.

if i don't change the child's version number, a minified version of the parent, matching the version number of the child's appears loading after.

below is all the code and screenshots of what i'm trying to explain.

functions.php of child-theme:

function my_theme_enqueue_styles() {

$parent_style = 'parent-style'; 

wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.min.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' );

style.css of child-theme:

/*!
Theme Name: Customify Child 
Theme URI: https://wpcustomify.com
Author: JNK XI
Author URI: https://
Description:  Customify Child Theme
Template: customify
Version: 0.1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: customify-child
Domain Path: /languages
Tags: custom-background, custom-logo, custom-menu, custom-logo, featured-images, flexible-header, footer-widgets, full-width-template, sticky-post, theme-options, threaded-comments, translation-ready, one-column, two-columns, three-columns, left-sidebar, right-sidebar, e-commerce, blog
*/

Console Printscreen if version of child-theme stylesheet is different from parent's

Console Printscreen if version of child-theme stylesheet is different from parent's

Console Printscreen if version of child-theme stylesheet matches parent's

Console Printscreen if version of child-theme stylesheet matches parent's

Please tell me if something is unclear.

any help would be appreciated, thank you

2
  • Does it actually appear after the child theme's CSS in the source code? I'm not sure if that list is sorted based on which file appears in the source code first.
    – Johansson
    Jun 22, 2018 at 2:17
  • The answer below is correct, in that you should investigate the source code of the generated page to see the loading order, and secondly that way you could find the handler too. But if this is a problem with a particular element where the parent style is overriding some css, you could simply use a more specific selector, example .page .widget h2 instead of .widget h2.
    – D. Dan
    Jun 22, 2018 at 6:26

1 Answer 1

1

Is the $parent_style variable in your the code literally $parent_style = 'parent-style';?

If so, that's your issue. It looks like you're using the example in the codex here and that's fine but you may have missed this bit right below the snippet:

where parent-style is the same $handle used in the parent theme when it registers its stylesheet. For example, if the parent theme is twentyfifteen, by looking in its functions.php for its wp_enqueue_style() call, you can see the tag it uses there is 'twentyfifteen-style'. In your child code, replace the instance of 'parent-style' with 'twentyfifteen-style'

In the case of the Customify theme, the "$handle" is built in a PHP function making it a little confusing. After looking at the theme code, it looks like the style sheet's handle is 'customify-style'.

With that knowledge, try replacing

$parent_style = 'parent-style';

with:

$parent_style = 'customify-style';

Disclaimer: I've only glanced at the theme's code, the style's handle may be different than what I've written here. If that's the case you should attempt to find the actual name the theme's style sheet is registered or enqueued with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.