How to Fix Salient Child Theme Not Working

Salient is a fantastic WordPress theme, but you may be having trouble getting your salient child theme to override the salient parent theme style.css file. This came to my attention while working on a client website using Salient 7.6.

It took me a while to figure out, but after clicking “View Source” it occurred to me it was pulling a file that didn’t exist (well, not yet anyways… this file did pop up later, but during development you don’t always have time to wait):

Your next two questions might be, 1) “Why is manually appending a CSS version number to the stylesheet link rel?” and 2) “How can the code be modified to remove this manual appending of the 7.6 version number?”

If you look in Salient’s parent theme functions.php file, you’ll find the following on or around line 304:

But rather than modify the parent theme’s functions.php file, which we all know is a no-no because your changes will be overwritten during regular theme updates — fortunately, you can simply add some code to your Salient child theme’s functions.php file and maintain the fix permanently:

In this case, we simply add the line: 

wp_register_style("main-styles", get_stylesheet_directory_uri() . '/style.css');

to the beginning of our child theme’s functions.php file.

But even with this fix in place, you may still find that your updates to the salient child theme’s style.css file aren’t showing up on your site. This is most likely due to your browser loading cached versions of your style.css file, and it’s a huge PITA during development.

The final blow is to force WordPress to serve your most recently-updated style.css file from your child theme:

To accomplish this, we simply added the line: 

$style_ver = time( filemtime( get_stylesheet_directory_uri() . '/style.css' ) );

above the previous line we added, then appended the text  , ”, $style_ver  to the end of our original line. This yields a grand total of these two lines of code, at the top of your child theme’s functions.php file:

$style_ver = time( filemtime( get_stylesheet_directory_uri() . '/style.css' ) );
wp_register_style("main-styles", get_stylesheet_directory_uri() . '/style.css', '', $style_ver );

Make Sure Your Child Theme is Named “Salient-child”

One more point, you need to make sure your child theme is named “Salient-child” and check that the Template: salient is spelled correctly because it’s case sensitive.

Follow these steps and you should be in great shape.