doxrxwn2252 2016-10-01 15:18
浏览 96
已采纳

子主题不从父主题加载整个样式

this is my test page e-commerce shop: https://shop.amir-rahbaran.com/

this is the parent style: https://colorlib.com/shapely

functions.php:

<?php
function my_theme_enqueue_styles() {

    $parent_style = 'parent-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')
    );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>

The shapely-master (parent) and shapely-child are both located in the theme folder (same hierarchy).

This is my shapely-child style.css:

/*
Theme Name: Shapely-Child
Template: shapely
Theme URI: https://colorlib.com/wp/themes/shapely
Author: colorlib - modified by Sandra J. / Amir R.
Author URI: https://colorlib.com/
Description: [...]
Version: 1.0.5
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: shapely
[ ... ]
*/
  • 写回答

2条回答 默认 最新

  • douwu8524 2016-10-04 14:42
    关注

    To make it work you can try replacing the code of function my_theme_enqueue_styles with the following modified code.

      function my_theme_enqueue_styles() {
    
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css', array('shapely-bootstrap') );
        wp_dequeue_style('shapely-style');
        wp_enqueue_style( 'shapely-style',
            get_stylesheet_directory_uri() . '/style.css',
            array('parent-style')
        );
    }
    

    To resolve the issue please make change in the function my_theme_enqueue_styles as i have described above and then change the following line in the style.css file of your child theme

    Template: shapely

    with the following line.

    Template: shapely-master

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度