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.
Savior!! I’ve been digging around for hours trying to understand why it wasn’t pulling from my child CSS file. THANK YOUUU!
You’re welcome Brian! Glad this was helpful for you.
This helped me so much! but, I have a question. I use buddypress and I want to customize the member loop, I created directories in child-theme, but it doesn’t work. Do you know any fixes for that, please?
Hi Katerina! When creating directories in the child-theme for templates that override plugins, they usually have to match the same directory hierarchy as the plugin – but not every time. I’ve run into issues with this when customizing WooCommerce, for example, and had to play around with several directory configurations before finding the magic one.
I’m not too familiar with buddypress myself, and I’d probably need more information to help you troubleshoot – but please feel free to reply with more info if you need additional help.
thanks for this post! it was driving me nuts .. its working in the sense that the CSS from the child theme is used now, but I get some other messages, as well as some funny layout problems. any Idea what that could be? im not expert and cant really read php code.
failed for http://thecuriousmind.apps-1and1.net/wp-content/themes/salient-child/style.css in /MyWebsite/wp-content/themes/salient-child/functions.php on line 3
Warning: Cannot modify header information – headers already sent by (output started at /MyWebsite/wp-content/themes/salient-child/functions.php:3) in /MyWebsitewp-admin/includes/misc.php on line 1114
Hey Panda! You’re welcome.
The first thing that comes to mind when seeing “headers already sent” is you might have a cache issue. If you’re using any server-side (or plugin-based) cache mechanisms, try disabling them and see if that rectifies the matter.
If that doesn’t work, the next thing that comes to mind are potential theme / plugin conflicts. I hate to give you the old “disable all your plugins and revert to stock WP theme” advice, but it’s worth a try if you’re still encountering issues. It’s pretty easy to rename your plugin folder something like “plugin-old” for a few minutes to disable all plugins and see if any difference is made.
Beyond that, it would probably require a more in-depth look at your specific site to diagnose and troubleshoot the matter. Please feel free to contact me directly if you need any further help.
the most likely answer to the “headers already sent” problem is that you closed out the PHP when it wasn’t expecting to be closed. I did this recently on a plugin I created and it gave me this error. Once I found the offending <? tag, I deleted it and it was all back to normal. No doubt by now you found the answer anyway, but it might help future readers of this thread.