donglang1976 2017-03-14 18:36
浏览 62

WordPress子主题不格式化

I'm aware that people have had similar issues, but reading through questions here on stackoverflow, and on WP Codex, has not helped me to solve this issue. This is the second child theme I've made. The first one worked perfectly. For some reason, even though I did everything the same, this one does not reflect the formatting of the parent theme. My suspicion is that I either need to enqueue multiple .css for this particular theme, or I have an incorrect tag. Hoping that a new set of eyes could find the problem.

Here is the style.css for the child theme:

/*
Theme Name: Kale-child
Theme URI: https://panaceats.com/
Author: ****
Author URI: https://panaceats.com/
Description: child theme of Kale
Template: kale
Version: 1.0.0
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.en.html
Text Domain: kale
Domain Path: /languages/
Tags: one-column, two-columns, three-columns, right-sidebar, grid-layout, flexible-header, custom-background, custom-colors, custom-header, custom-menu, featured-images,footer-widgets, full-width-template, theme-options, threaded-comments, translation-ready, food-and-drink
*/

And here is the functions.php for the child theme:

<?php
function my_theme_enqueue_styles() {

$parent_style = 'kale-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' );
?>

As you can see, I have followed the directions from the WP Codex - CT.

This is what the formatting is supposed to look like.

UPDATE: I have now got my child theme looking like the parent theme by copy/pasting all the content from the parent style.css to the child. However, doesn't this defeat the purpose of enqueue? If I have the parent and child enqueued correctly, shouldn't the formatting from the parent reflect in the child theme?

  • 写回答

2条回答 默认 最新

  • douxiong2738 2017-04-12 16:22
    关注

    Try this in your child theme's functions file. It seemed to do the trick for me.

    <?php
        add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
        
        function enqueue_parent_styles() {
    
               $deps = array('bootstrap', 'bootstrap-select', 'font-awesome', 'owl-carousel');
                   wp_enqueue_style('kale-style', get_template_directory_uri() . '/style.css', $deps );
    
    
        
            }
        
    ?>

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作