首页 > 解决方案 > 我的 wordpress 子主题使用父母的主题字体系列,无论我在我的子主题 css 中选择什么字体

问题描述

我尝试在我的子主题中应用不同的字体系列,但主题使用父主题的字体。其他 css 属性工作正常。我只有 font-family 属性才有这个问题。它仅在我使用 !important 时有效。任何帮助深表感谢。

子主题的 function.php 文件:

<?php

add_action( 'wp_enqueue_scripts', 'load_theme_assets' );

function load_theme_assets() {

$parent_style = 'parent-style';

wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );

# Loading Child Theme Main Stylesheet
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css');

# Loading AOS Stylesheet
wp_enqueue_style( 'aos', get_stylesheet_directory_uri() . '/assets/css/aos.css');

# Loading Owl Carousel Stylesheet
wp_enqueue_style( 'owl-carousel', get_stylesheet_directory_uri() . '/assets/css/owl.carousel.css');

# Loading Owl Carousel Theme Default Stylesheet
wp_enqueue_style( 'owl-theme-default', get_stylesheet_directory_uri() . '/assets/css/owl.theme.default.css');

# Loading Google Fonts
wp_enqueue_style( 'custom-google-fonts', 'https://fonts.googleapis.com/css?family=Lora|Martel|Noto+Serif+SC|Playfair+Display&display=swap', false);

# Loading Font Awesome Icons
wp_enqueue_style( 'all', get_stylesheet_directory_uri() . '/assets/css/all.css');

还有我的 CSS 文件:

body    {
    border: 1px solid #999;
    background-color: #F9F8F8;
    font-family: 'Martel', serif;
}

所以,我可以看到边框和背景发生了变化,但字体保持不变。

标签: csswordpressfontswordpress-theming

解决方案


推荐阅读