0

I'm using a child theme with a style.css file and none of the updates are showing on the live site.

  • When I view the child theme style.css file via "view page source" the changes show in the code.
  • The changes don't show in "developer tools". Not even as being overwritten. They just don't exist.
  • The site only shows CSS code from a "style-less.css" file.
  • If I add the code via the Admin Panel (Appearance > Customize > Additional CSS) the changes work.

I don't believe this is a caching issue, because I've cleared server and browser caches. I've also went back and looked at changes I made 6+ months ago, and we still have the same issue.

What do I need to do so that my child themes style.css changes are reflected on the live site?

4
  • If you can see the stylesheet is loaded by checking the HTML of the page and the network tab, but you can’t even see the styles applied to the element with the inspector then the issue is almost certainly that your CSS is incorrect. If the stylesheet is showing up in the HTML at all then the WordPress part is working. Anything else has to be the CSS itself or your server, not WordPress. Jun 6, 2022 at 17:53
  • If I copy and paste the same exact code into the Admin panel of Wordpress (as noted above) it works immediately. So it's not the CSS code itself. What about the server could be the issue, so I can look into this more?
    – Derek
    Jun 6, 2022 at 17:56
  • Are you copying the entirety of the CSS? If you just have one rule that isn’t working you probably have a syntax problem earlier in the CSS file that is preventing the rest of it working. Jun 6, 2022 at 18:28
  • And if it’s a server problem you’d see an issue in the network tab. Jun 6, 2022 at 18:29

1 Answer 1

0

You must enqueue your child theme's stylesheet from the child theme's functions.php file, as you would any other stylesheet. Specifying the parent theme's stylesheet handle as a dependency is a good measure to ensure the proper load order.

function wpse406477_enqueue_child_styles() {
  wp_enqueue_style( 'mychild-style', get_stylesheet_uri(), [ 'parent-style' ] );
}

add_action( 'wp_enqueue_scripts', 'wpse406477_enqueue_child_styles' );

Note that compatibility with traditional mechanisms to override parent components from child themes varies from theme to theme. If your parent theme is not one of the default twenty* themes, you may need to refer to your theme's documentation or inquire in the theme's official support channels for the proper means to extend it with a child theme.

1
  • I have it enqueued. function motor_child_scripts_styles() { wp_enqueue_style( 'motor-parent-style', get_template_directory_uri(). '/style.css' ); } add_action( 'wp_enqueue_scripts', 'motor_child_scripts_styles' ); I asked the theme developer previously and their response was that it was a caching issue. But that doesn't seem to be the case based on the information given above (clearing caches, and updates from months ago still not appearing). Their documentation is thin, and they just ended support... so I'm kinda stuck trying to find a solution.
    – Derek
    Jun 6, 2022 at 17:45

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.