• So, I’m attempting to make a child theme based of the Flexible Theme from Elegant Themes. However, the parent theme has multiple style sheets. One style.css in the root folder, and four more in the “css” folder off the root.

    I created a new template folder on the server and uploaded a modified style.css (it shows up in the appearance panel), and a functions.php. However, the latter is tripping me up.

    First question is how should the php look if I have several style sheets to reference?

    Like this ?

    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/css/secondstyle.css' );
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/css/thirdstyle.css' );
    
    }

    If so, the directory is always listed as starting with a “/.” However, if my parent theme is in a folder outside of my child theme’s folder, doesn’t the directory have to be more specific?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Elegant Themes is the ones to ask about this – these forums don’t support commercial themes, sorry.

    @wpyohi the OP had a pretty generic question but just so happens to use a commercial theme. The root of the question is how to enqueue multiple stylesheets from a parent theme. I found this thread from a Google search and figured this out from another thread. I don’t know exactly why this works but in case this helps anyone, it appears 2 enqueues can’t be “named” the same. ‘parent-style’ and ‘parent-mediaqueries’ worked for my situation.

    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'parent-mediaqueries', get_template_directory_uri() . '/mediaqueries.css', array(), '' );
        wp_enqueue_style( 'child-style',
            get_stylesheet_directory_uri() . '/style.css',
            array('parent-style')
        );
    }
    Noodles

    (@snugbabyshop)

    Thanks inhouse! Yes, I agree that this a generic question for which I could not find a proper answer until now. Cheers!

    Same here — very helpful. Thank you!

    I’m having the same issue – can someone please explain it a little bit to me? I’m learning as I go and i think I’m having trouble understanding the syntax in relation to this. Basically, I want to make changes in the parent css files and upload the changes in the child. Please help! I’m providing a link of to a screenshot of my screen. (Caution: might look super dumb!)

    https://fbcdn-sphotos-e-a.akamaihd.net/hphotos-ak-xpa1/t31.0-8/12022597_10153276779562858_8231746904147172687_o.jpg

    Hello Inhouse,
    I am trying to cheate a child theme for twentyfifteen which has 3 css files. I tried your way of enqueueing but am not able to generate my child theme. Could you please help me identify my errors
    Here goes the functions.PHP of my- twentyfifteen-child

    <?php
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles');
    
    function theme_enqueue_styles() {
    
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    	wp_enqueue_style( 'parent-mediaqueries', get_template_directory_uri() . '/mediaqueries.css', array(),'');
    	wp_enqueue_style( 'child-style',
        	get-stylesheet-directory-uri(). '/style.css',
    	    array( 'parent-style' )
    	);
    
    }

    I’m thinking you may have issues with your stylesheet header which names your child theme and determines whether it is a child of another theme. Have you read through the child theme docs in Codex? What do you see in Appearance > Themes?

    /*
     Theme Name:   Twenty Fifteen Child
     Theme URI:    https://example.com/twenty-fifteen-child/
     Description:  Twenty Fifteen Child Theme
     Author:       John Doe
     Author URI:   https://example.com
     Template:     twentyfifteen
     Version:      1.0.0
     License:      GNU General Public License v2 or later
     License URI:  https://www.gnu.org/licenses/gpl-2.0.html
     Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
     Text Domain:  twenty-fifteen-child
    */
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Flexible theme Multiple CSS Enqueue for Child Theme’ is closed to new replies.