Site logo

Archived topic

Child Master CSS

3 replies · Started by Kevin on April 7, 2019

Viewing posts 1–4 of 4

Hi, I have a multisite using Generatepress child themes.
I can add custom CSS for each child in the CSS file, that's perfect.

Question: How can I create CSS rules on the parent theme (Generatepress) which will affect all children?
I normally edited the core style.css of the parent, but it would break when updated.

Hi there,

how about creating a separate style sheet for the parent level changes and enqueuing that from within your child theme functions?

Hi David, yes that would be nice, could you help me writing it correctly?
Does it have to be a function?

I googled and tried this, but it's not working yet.
I wrote this in the child functions.php (and placed a CSS file in the parent theme):

wp_enqueue_style( 'style-test', get_template_directory_uri() . 'style-test.css' );

I think you'd actually need to create a plugin to enqueue a CSS file on all sites.

You can create a plugin with a plugin like this: https://wordpress.org/plugins/pluginception/

Then you can use a function like this inside of it:

add_action( 'wp_enqueue_scripts', function() {
    wp_enqueue_style( 'network-style', plugin_dir_url( __FILE__ ) . 'style.css' );
} );

This assumes the style.css file is in the root of your plugin folder.

Then you can network activate the plugin, and your file should be active across the network.

This archived topic is closed to new replies.