0

I have inherited a site without a child theme and now we will have problems when it comes to update things. Everything in this theme was made on the main theme...

I have now created a child theme but I have to enqueue a lot of scripts and stylesheets and I'm not doing it correctly. The main issue is, I have these custom stylesheets in a css folder in my child theme directory. But the functions look for these files on the parent theme so it doesn't find them obviously. Should I upload a custom stylesheet on the parent css directory? Or have it on my child theme directory and enqueue it differently?

Here's how my functions.php on my child theme look:

function shopkeeper_styles_child() {

    global $shopkeeper_theme_options;

    wp_enqueue_style('shopkeeper-foundation-app', get_template_directory_uri() . '/css/app.css', array(), '5.3.1', 'all' );     

    wp_enqueue_style('shopkeeper-animate', get_template_directory_uri() . '/css/animate.css', array(), '2.0', 'all' );

    wp_enqueue_style('shopkeeper-font-awesome', get_template_directory_uri() . '/inc/fonts/font-awesome/css/font-awesome.min.css', array(), '4.0.3', 'all' );
    wp_enqueue_style('shopkeeper-font-linea-arrows', get_template_directory_uri() . '/inc/fonts/linea-fonts/arrows/styles.css', array(), '1.0', 'all' );
    wp_enqueue_style('shopkeeper-font-linea-basic', get_template_directory_uri() . '/inc/fonts/linea-fonts/basic/styles.css', array(), '1.0', 'all' );
    wp_enqueue_style('shopkeeper-font-linea-basic_elaboration', get_template_directory_uri() . '/inc/fonts/linea-fonts/basic_elaboration/styles.css', array(), '1.0', 'all' );
    wp_enqueue_style('shopkeeper-font-linea-ecommerce', get_template_directory_uri() . '/inc/fonts/linea-fonts/ecommerce/styles.css', array(), '1.0', 'all' );
    wp_enqueue_style('shopkeeper-font-linea-music', get_template_directory_uri() . '/inc/fonts/linea-fonts/music/styles.css', array(), '1.0', 'all' );
    wp_enqueue_style('shopkeeper-font-linea-software', get_template_directory_uri() . '/inc/fonts/linea-fonts/software/styles.css', array(), '1.0', 'all' );
    wp_enqueue_style('shopkeeper-font-linea-weather', get_template_directory_uri() . '/inc/fonts/linea-fonts/weather/styles.css', array(), '1.0', 'all' );  
    wp_enqueue_style('shopkeeper-fresco', get_template_directory_uri() . '/css/fresco/fresco.css', array(), '1.3.0', 'all' );
    wp_enqueue_style('shopkeeper-idangerous-swiper', get_template_directory_uri() . '/css/idangerous.swiper.css', array(), '', 'all' );
    wp_enqueue_style('shopkeeper-owl', get_template_directory_uri() . '/css/owl.carousel.css', array(), '1.3.1', 'all' );
    wp_enqueue_style('shopkeeper-owl-theme', get_template_directory_uri() . '/css/owl.theme.css', array(), '1.3.1', 'all' );
    wp_enqueue_style('shopkeeper-offcanvas', get_template_directory_uri() . '/css/offcanvas.css', array(), '1.0', 'all' );
    wp_enqueue_style('shopkeeper-nanoscroller', get_template_directory_uri() . '/css/nanoscroller.css', array(), '0.7.6', 'all' );
    wp_enqueue_style('shopkeeper-select2', get_template_directory_uri() . '/css/select2.css', array(), '3.4.5', 'all' );
    wp_enqueue_style('shopkeeper-easyzoom', get_template_directory_uri() . '/css/easyzoom.css', array(), '1.0', 'all' );
    wp_enqueue_style('shopkeeper-defaults', get_template_directory_uri() . '/css/defaults.css', array(), '1.0', 'all' );
    wp_enqueue_style('shopkeeper-woocommerce-overwrite', get_template_directory_uri() . '/css/woocommerce-overwrite.css', array(), '1.0', 'all' );
    wp_enqueue_style('shopkeeper-top-bar', get_template_directory_uri() . '/css/header-topbar.css', array(), '1.0', 'all' );
    wp_enqueue_style('shopkeeper-headers', get_template_directory_uri() . '/css/headers.css', array(), '1.0', 'all' );
    wp_enqueue_style('shopkeeper-menus', get_template_directory_uri() . '/css/navigations.css', array(), '1.0', 'all' );
    wp_enqueue_style('shopkeeper-custom', get_template_directory_uri() . '/shoopkeeper-child/css/custom_artiq.css', array(), '1.0', 'all' );

    if ( isset($shopkeeper_theme_options['main_header_layout']) ) {     
        if ( $shopkeeper_theme_options['main_header_layout'] == "1" ) {
            wp_enqueue_style('shopkeeper-header-default', get_template_directory_uri() . '/css/header-default.css', array(), '1.0', 'all' );
        }       
        elseif ( $shopkeeper_theme_options['main_header_layout'] == "2" ) {
            wp_enqueue_style('shopkeeper-header-centered-2menus', get_template_directory_uri() . '/css/header-centered-2menus.css', array(), '1.0', 'all' );
        }
        elseif ( $shopkeeper_theme_options['main_header_layout'] == "3" ) {
            wp_enqueue_style('shopkeeper-header-centered-menu-under', get_template_directory_uri() . '/css/header-centered-menu-under.css', array(), '1.0', 'all' );
        }       
    }       
    else {  
        wp_enqueue_style('shopkeeper-header-default', get_template_directory_uri() . '/css/header-default.css', array(), '1.0', 'all' );    
    }

    if (isset($shopkeeper_theme_options['font_source']) && ($shopkeeper_theme_options['font_source'] == "2")) {
        if ( (isset($shopkeeper_theme_options['font_google_code'])) && ($shopkeeper_theme_options['font_google_code'] != "") ) {
            wp_enqueue_style('shopkeeper-font_google_code', $shopkeeper_theme_options['font_google_code'], array(), '1.0', 'all' );
        }
    }

    wp_enqueue_style('shopkeeper-styles', get_template_directory_uri() . '/css/styles.css', array(), '1.0', 'all' );
    wp_enqueue_style('shopkeeper-responsive', get_template_directory_uri() . '/css/responsive.css', array(), '1.0', 'all' );

    wp_enqueue_style('shopkeeper-default-style', get_stylesheet_uri());

}
add_action( 'wp_enqueue_scripts', 'shopkeeper_styles_child', 99 );
2

Use: wp_enqueue_style( 'test', get_stylesheet_directory_uri() . '/css/test.css' );

instead of get_template_directory_uri();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.