Дочерняя тема магазина все еще загружает родительский CSS - PullRequest
0 голосов
/ 27 декабря 2018

У меня проблема с дочерней темой Storefront.Я создал дочернюю тему Storefront, как они предлагают здесь: https://docs.woocommerce.com/document/set-up-and-use-a-child-theme/

Дочерняя тема работает нормально, я могу написать свой CSS, написать свой код в functions.php и переопределить файлы шаблона, но дочерняя тема по-прежнему загружаетсяродительская тема CSS.

Как создать дочернюю тему без загруженного родительского CSS?

1 Ответ

0 голосов
/ 27 декабря 2018

Добавьте эти функции в functions.php вашей дочерней темы.

Этот код отключит загрузку CSS по умолчанию для Витрины магазина.

Источник: https://github.com/stuartduff/storefront-child-theme

/**
 * 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' );
}

Кроме того, вы можете отключить стандартные таблицы стилей WooCommerce,

Источник: https://docs.woocommerce.com/document/disable-the-default-stylesheet/

/**
 * Set WooCommerce image dimensions upon theme activation
 */
// Remove each style one by one

add_filter( 'woocommerce_enqueue_styles', 'jk_dequeue_styles' );

function jk_dequeue_styles( $enqueue_styles ) {
    unset( $enqueue_styles['woocommerce-general'] );    // Remove the gloss
    unset( $enqueue_styles['woocommerce-layout'] );     // Remove the layout
    unset( $enqueue_styles['woocommerce-smallscreen'] );    // Remove the smallscreen optimisation
    return $enqueue_styles;
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...