Made a child theme for Storefront according to the instructions .

In the file / wp-content / themes / storefront / inc / class-storefront.php , styles and scripts are included . (line 204)

I need to add my own styles, for example bootstrap, copy the class-storefront.php file to my theme /wp-content/themes/mytheme/inc/class-storefront.php and leave only the function there

public function scripts() { global $storefront_version; /** * Styles */ wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.min.css', array("storefront-style") ); } 

bootstrap in the head is not connected, put it in /wp-content/themes/storefront/assets/css/bootstrap.min.css and in /wp-content/themes/mytheme/assets/css/bootstrap.min.css anyway not connected

What is wrong with class-storefront.php?

    1 answer 1

    What's happening

    Not all theme files can be copied to a child and expect that they will be picked up. Usually this is specifically indicated by developers in the comments, at the very top of the php file.

    For example, open the wp-content/plugins/woocommerce/templates/content-product.php file from the WooCommerce plugin and read the comment above. This functionality is provided by the plugin code.

    Some core theme files like header.php , footer.php , page.php , etc., are picked up by the WordPress core, if they are present in a child theme.

    What to do

    The class-storefront.php contains the class definition. You can create your own successor class Storefront from the class Storefront and substitute functions in it.

    But for your task and you do not need it. Paste this code into the functions.php of the child theme:

     function my_styles() { wp_enqueue_style( 'bootstrap', get_stylesheet_directory_uri() . '/bootstrap.min.css', array("storefront-style") ); } add_action( 'wp_enqueue_scripts', 'my_styles' ); 

    and put the bootstrap.min.css file in the child theme folder.

    • I put the styles in the child theme, I look into the browser and there <link rel = "stylesheet" id = "bootstrap-css" href = "... / wp-content / themes / storefront / assets / css / bootstrap.min.css? ver = 4.8.2 "type =" text / css "media =" all "> All styles and scripts of the path are written in the storefront - Sergei R
    • Did you copy the code exactly? stylesheet, not template - KAGG Design
    • Thank you my mistake was. - Sergei R
    • Good advice. It works great with every single file from the css folder copied to a child theme. But there these files are MUCH. Is there a function that immediately redirects the entire folder? - Inga Urbanovskaya
    • There is no such function. But redirecting the entire folder is a bad decision. Work only with the files you are editing. - KAGG Design