[Support request] Child Master CSS

Home Forums Support [Support request] Child Master CSS

Home Forums Support Child Master CSS

  • This topic has 3 replies, 3 voices, and was last updated 5 years ago by Tom.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #862452
    Kevin

    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.

    #862735
    David
    Staff
    Customer Support

    Hi there,

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

    #862747
    Kevin

    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' );

    #863352
    Tom
    Lead Developer
    Lead Developer

    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.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.