devellopah
@devellopah

Почему не выходит подключить bootstrap в дочерней теме(wordpress)?

Установил woocommerce на сайт, кинул в папку themes их тему Storefront, скачал стартер дочерней темы, как они и рекомендуют, отсюда, активировал её, в файле functions.php добавил скрипт(посмотрел его здесь), чтобы подключить bootstrap
Вот так выглядит functions.php

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


Однако bootstrap не вижу в head. По идее, должен был подключиться после
<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">

как у чувака в видео.
Помогите разобраться, наверняка вы уже это делали.

p.s. пока временно подключил по cdn, чтобы начать верстать
  • Вопрос задан
  • 1009 просмотров
Пригласить эксперта
Ответы на вопрос 1
Palych_tw
@Palych_tw
Типа веб-разработчик
Так а бутстрап где у вас лежит? В разметке совсем нет линка на него или просто выдает 404? Сделайте поиск по коду страницы. Если нет тега, попробуйте изменить id скрипта с "bootstrap" на что-нибудь другое, возможно стиль с таким же id уже подключается в родительской теме. А так на первый взгляд все написано правильно

UPD : Какие же мы не внимательные)) хук называется wp_enqueue_scriptS !! исправь
add_action('wp_enqueue_scripts', 'champfood_enqueue_styles');
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
28 мар. 2024, в 20:46
150000 руб./за проект
28 мар. 2024, в 20:37
50000 руб./за проект
28 мар. 2024, в 20:34
1500 руб./за проект