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条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?