I
I
Islam Ibakaev2017-10-01 12:16:49
PHP
Islam Ibakaev, 2017-10-01 12:16:49

Why can't I connect bootstrap in a child theme (wordpress)?

I installed woocommerce on the site , threw their Storefront theme into the themes folder, downloaded the child theme starter, as they recommend, from here , activated it, added a script in the functions.php file (I looked at it here ) to connect bootstrap
This is how functions.php looks like

<?php

/**
 * Storefront automatically loads the core CSS even if using a child theme as it is more efficient
 * than @importing it in the child theme style.css file.
 *
 * Uncomment the line below if you'd like to disable the Storefront Core CSS.
 *
 * If you don't plan to dequeue the Storefront Core CSS you can remove the subsequent line and as well
 * as the sf_child_theme_dequeue_style() function declaration.
 */
//add_action( 'wp_enqueue_scripts', 'sf_child_theme_dequeue_style', 999 );

/**
 * Dequeue the Storefront Parent theme core CSS
 */
function sf_child_theme_dequeue_style() {
    wp_dequeue_style( 'storefront-style' );
    wp_dequeue_style( 'storefront-woocommerce-style' );
}

/**
 * Note: DO NOT! alter or remove the code above this text and only add your custom PHP functions below this text.
 */

function champfood_enqueue_styles() {
  $parent_style = 'parent-style'; // storefront style
  wp_enqueue_style($parent_style, get_template_directory_uri() . '/style.css');
  wp_enqueue_style(
    'child-style', 
    get_stylesheet_directory_uri() . '/style.css',
    array($parent_style),
    wp_get_theme()->get('Version')
  );
  wp_enqueue_style(
    'bootstrap',
    get_stylesheet_directory_uri() . '/assets/bootstrap/bootstrap.css');
  

}

add_action('wp_enqueue_script', 'champfood_enqueue_styles');

However, I don't see bootstrap in head. In theory, I should have connected after
<link rel="stylesheet" id="storefront-child-style-css" href="http://champfood.mosco-web.ru/wp-content/themes/champfood/style.css?ver=4.8.2" type="text/css" media="all">

like the guy in the video.
Please help me, I'm sure you've already done this.
ps so far temporarily connected via cdn to start typesetting

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2017-10-01
@Palych_tw

So where do you have your bootstrap? Is there no link to it in the markup or does it just give a 404? Search by page code. If there is no tag, try changing the id of the script from "bootstrap" to something else, perhaps the style with the same id is already included in the parent theme. And so at first glance everything is written correctly
UPD : What are we not attentive)) the hook is called wp_enqueue_scriptS !! fix it

add_action('wp_enqueue_scripts', 'champfood_enqueue_styles');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question