Hello,
I’m developing a child theme of vantage, and ran across what seems like an odd behavior in how WordPress child themes work. In functions.php, vantage_scripts enqueues Vantages’s styles.css with this call:
wp_enqueue_style( 'vantage-style', get_stylesheet_uri(), array(), SITEORIGIN_THEME_VERSION );
However, when there is a child theme, this actually resolves to style.css in the child theme instead of in Vantage. In order for Vantage’s css to be correctly included in this case, the child theme must override the ‘vantage-style’ inclusion by doing this:
wp_enqueue_style('vantage-style', get_template_directory_uri() . '/style.css');
This strikes me as being both fragile and breaking modularity, that the child theme would need to know inner details of the parent theme. It would be simpler if each theme were only responsible for its own stylesheets, i.e., Vantage would use get_template_directory_uri() instead of get_stylesheet_uri() to build the uri of its style.css.
Is this a change that would make sense for Vantage to adopt, or are there other cases to consider where the current way is superior?
Thank you,
Hi Jjfoerch,
Unfortunately, this isn’t something we can ever regardless of what method is superior. Too many child themes rely on the current method so releasing an update that changes things could cause major issues for major issues for certain user. We recommend adding the following PHP to your child theme:
Regardless of this, there is an advantage to how we’re doing things. Basically, it allows the designer to completely remove the default stylesheet out of the mix and thus not have to fight with it if they so desire.
Hi Alex,
Ah, I see. Thank you so much for the explanation.