Please confirm theme style load priority

Could a member of the support team please confirm the loading hierarchy of the theme stylesheets?

I found this on another post, but this doesn’t seem to be reflected in the latest Pro version.

  • X Theme’s stack style.css
  • X Child theme’s style.css
  • WordPress Customizer’s Additional CSS
  • X > Theme Options settings
  • X > Theme Options’ global css
  • Cornerstone’s page css

I’m currently seeing the Child theme style.css loading (and hence having lower priority) than the Parent theme stack style.css.

Thanks

Hi Steward,

Parent theme is loading first then child theme styles. See this: https://screencast-o-matic.com/watch/cYeh6wxjSa

Parent theme style will take effect first then can be overwritten by the child theme styles unless a selector is more specific.

Hope this helps.

Perfect. Now … how can I force the child theme stylesheet to load after the Gravity Form stylesheets? I notice in the recent update there was mention of a fix for Gravity Forms stylesheets, however, the Gravity Forms stylesheets are loading after the child CSS meaning they have priority and my child css overrides are not being applied.

Thanks

Hello Stewart,

To resolve your issue, assuming that your child theme is set up, please add the following code in your child theme’s functions.php file

// Dequeue and Enqueue Child theme with higher priority number
// =============================================================================
function custom_x_enqueue_site_styles() {
	wp_dequeue_style('x-child');
	$rev = ( defined( 'X_CHILD_ASSET_REV' ) ) ? X_CHILD_ASSET_REV : X_ASSET_REV;
	wp_enqueue_style( 'x-child', get_stylesheet_directory_uri() . '/style.css', array(), $rev, 'all' );
}
add_action( 'wp_enqueue_scripts', 'custom_x_enqueue_site_styles', 50 );
// =============================================================================

Please note that custom coding is outside the scope of our support. Issues that might arise from the use of custom code and further enhancements should be directed to a third party developer.

We would love to know if this has worked for you. Thank you.

Hi, this only worked when I changed the priority to 99.

It seems odd that the latest versions of Pro forces the Gravity Forms CSS files to be loaded after the Theme CSS files. Could you raise this with the developers please?

Thanks

Hello Stewart,

Since the 99 priority works for you, then you will have to use it. Keep in mind that by default, WordPress will load the theme style, child theme styles and then the plugin styles. Depending on the number of plugins, the plugin styles will be loaded last which is why you need the priority number to override the loading of the child theme styles.

Hope this makes sense.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.